* lisp.h: (XVECTOR_SIZE): Remove. All uses replaced with ASIZE.
[bpt/emacs.git] / src / ChangeLog
index 9a8177b..05d5c77 100644 (file)
-2011-04-20  Paul Eggert  <eggert@cs.ucla.edu>
+2011-04-25  Paul Eggert  <eggert@cs.ucla.edu>
 
-       * intervals.h (struct interval): Use EMACS_INT for members
-       where EMACS_UINT might cause problems.  See
-       <http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00514.html>.
-       (CHECK_TOTAL_LENGTH): Remove cast to EMACS_INT; no longer needed.
-       * intervals.c (interval_deletion_adjustment): Now returns EMACS_INT.
+       * lisp.h: (XVECTOR_SIZE): Remove.  All uses replaced with ASIZE.
+       (ASIZE): Now contains previous implementation of XVECTOR_SIZE
+       instead of invoking XVECTOR_SIZE.
+
+       * lisp.h: Say "vectorlike header" rather than "vector header.
+       (struct vectorlike_header): Rename from struct vector_header.
+       (XVECTORLIKE_HEADER_SIZE): Renamed from XVECTOR_HEADER_SIZE.
        All uses changed.
 
-       * alloc.c (overrun_check_malloc, overrun_check_realloc): Now static.
-       (overrun_check_free): Likewise.
+       lisp.h: Fix a problem with aliasing and vector headers.
+       GCC 4.6.0 optimizes based on type-based alias analysis.  For
+       example, if b is of type struct buffer * and v of type struct
+       Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
+       != &v->size, and therefore "v->size = 1; b->size = 2; return
+       v->size;" must therefore return 1.  This assumption is incorrect
+       for Emacs, since it type-puns struct Lisp_Vector * with many other
+       types.  To fix this problem, this patch adds a new type struct
+       vector_header that documents the constraints on layout of vectors
+       and pseudovectors, and helps optimizing compilers not get fooled
+       by Emacs's type punning.  It also adds the macros XSETTYPED_PVECTYPE
+       XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
+       * lisp.h (XVECTOR_SIZE): New convenience macro.  All previous uses of
+       XVECTOR (foo)->size replaced to use this macro, to avoid the hassle
+       of writing XVECTOR (foo)->header.size.
+       (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
+       (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
+       member.
+       (XSETPVECTYPE): Rewrite in terms of new macro.
+       (XSETPVECTYPESIZE): New macro, specifying both type and size.
+       This is a bit clearer, and further avoids the possibility of
+       undesirable aliasing.
+       (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
+       (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
+       and XVECTOR_HEADER_SIZE.
+       (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
+       since Lisp_Subr is a special case (no "next" field).
+       (ASIZE): Rewrite in terms of XVECTOR_SIZE.
+       (struct vector_header): New type.
+       (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
+       object, to help avoid aliasing.
+       (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
+       (SUBRP): Likewise, since Lisp_Subr is a special case.
+
+       * lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
+       (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
+       (struct Lisp_Hash_Table): Combine first two members into a single
+       struct vector_header member.  All uses of "size" and "next" members
+       changed to be "header.size" and "header.next".
+       * buffer.h (struct buffer): Likewise.
+       * font.h (struct font_spec, struct font_entity, struct font): Likewise.
+       * frame.h (struct frame): Likewise.
+       * process.h (struct Lisp_Process): Likewise.
+       * termhooks.h (struct terminal): Likewise.
+       * window.c (struct save_window_data, struct saved_window): Likewise.
+       * window.h (struct window): Likewise.
+       * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
+       Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
+       * buffer.c (init_buffer_once): Likewise.
+       * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
+       special case.
+       * process.c (Fformat_network_address): Use local var for size,
+       for brevity.
+
+2011-04-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
+
+2011-04-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        Make the Lisp reader and string-to-float more consistent.
        * data.c (atof): Remove decl; no longer used or needed.
-       (Fstring_to_number): Use new string_to_float function, to be
+       (digit_to_number): Move to lread.c.
+       (Fstring_to_number): Use new string_to_number function, to be
        consistent with how the Lisp reader treats infinities and NaNs.
        Do not assume that floating-point numbers represent EMACS_INT
        without losing information; this is not true on most 64-bit hosts.
        Avoid double-rounding errors, by insisting on integers when
        parsing non-base-10 numbers, as the documentation specifies.
-       Report integer overflow instead of silently converting to
-       integers.
-       * lisp.h (string_to_float): New decl, replacing ...
+       * lisp.h (string_to_number): New decl, replacing ...
        (isfloat_string): Remove.
-       * lread.c (read1): Do not accept +. and -. as integers; this
+       * lread.c: Include <inttypes.h>, for uintmax_t and strtoumax.
+       (read1): Do not accept +. and -. as integers; this
        appears to have been a coding error.  Similarly, do not accept
        strings like +-1e0 as floating point numbers.  Do not report
-       overflow for some integer overflows and not others; instead,
-       report them all.  Break out the floating-point parsing into a new
-       function string_to_float, so that Fstring_to_number parses
+       overflow for integer overflows unless the base is not 10 which
+       means we have no simple and reliable way to continue.
+       Break out the floating-point parsing into a new
+       function string_to_number, so that Fstring_to_number parses
        floating point numbers consistently with the Lisp reader.
-       (string_to_float): New function, replacing isfloat_string.
+       (digit_to_number): Moved here from data.c.  Make it static inline.
+       (E_CHAR, EXP_INT): Remove, replacing with ...
+       (E_EXP): New macro, to solve the "1.0e+" problem mentioned below.
+       (string_to_number): New function, replacing isfloat_string.
        This function checks for valid syntax and produces the resulting
-       Lisp float number too.
+       Lisp float number too.  Rework it so that string-to-number
+       no longer mishandles examples like "1.0e+".  Use strtoumax,
+       so that overflow for non-base-10 numbers is reported only when
+       there's no portable and simple way to convert to floating point.
+
+2011-04-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * textprop.c (set_text_properties_1): Rewrite for clarity,
+       and to avoid GCC warning about integer overflow.
+
+       * intervals.h (struct interval): Use EMACS_INT for members
+       where EMACS_UINT might cause problems.  See
+       <http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00514.html>.
+       (CHECK_TOTAL_LENGTH): Remove cast to EMACS_INT; no longer needed.
+       * intervals.c (interval_deletion_adjustment): Now returns EMACS_INT.
+       All uses changed.
+       (offset_intervals): Tell GCC not to worry about length overflow
+       when negating a negative length.
+
+       * alloc.c (overrun_check_malloc, overrun_check_realloc): Now static.
+       (overrun_check_free): Likewise.
 
        * alloc.c (SDATA_SIZE) [!GC_CHECK_STRING_BYTES]: Avoid runtime check
        in the common case where SDATA_DATA_OFFSET is a multiple of Emacs