aboutsummaryrefslogtreecommitdiffstats
path: root/src/ChangeLog
diff options
context:
space:
mode:
authorEli Zaretskii2011-05-09 05:59:23 -0400
committerEli Zaretskii2011-05-09 05:59:23 -0400
commit14fe7b530dc927a88169a841afc0cd806593dea8 (patch)
tree510192ce4c22c74ffec5b97327ea5e4a03a5a66c /src/ChangeLog
parent6eea50c73be34e865dabf14cbd2d0e7c4f64e6a0 (diff)
downloademacs-14fe7b530dc927a88169a841afc0cd806593dea8.tar.gz
emacs-14fe7b530dc927a88169a841afc0cd806593dea8.zip
Backport revisions 2011-04-24T05:30:24Z!eggert@cs.ucla.edu..2011-04-25T19:40:22Z!eggert@cs.ucla.edu (inclusive) from trunk (bug#8623)
The next log entry shows the actual changes by Paul Eggert. 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. src/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. src/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. (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. src/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". src/buffer.h (struct buffer): Likewise. src/font.h (struct font_spec, struct font_entity, struct font): Likewise. src/frame.h (struct frame): Likewise. src/process.h (struct Lisp_Process): Likewise. src/termhooks.h (struct terminal): Likewise. src/window.c (struct save_window_data, struct saved_window): Likewise. src/window.h (struct window): Likewise. src/alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector): Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems. src/buffer.c (init_buffer_once): Likewise. src/lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a special case. src/process.c (Fformat_network_address): Use local var for size, for brevity. src/fns.c (vector): Remove; this old hack is no longer needed. src/bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
Diffstat (limited to 'src/ChangeLog')
-rw-r--r--src/ChangeLog68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 42d9185e0dd..2a051a9e27b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,71 @@
12011-05-09 Eli Zaretskii <eliz@gnu.org>
2
3 Backport revisions 103939.1.41..103939.1.44 (inclusive) from trunk.
4 (bug#8623)
5 The next log entry shows the actual changes by Paul Eggert.
6
72011-05-08 Paul Eggert <eggert@cs.ucla.edu>
8
9 Fix a problem with aliasing and vector headers.
10 GCC 4.6.0 optimizes based on type-based alias analysis. For
11 example, if b is of type struct buffer * and v of type struct
12 Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
13 != &v->size, and therefore "v->size = 1; b->size = 2; return
14 v->size;" must therefore return 1. This assumption is incorrect
15 for Emacs, since it type-puns struct Lisp_Vector * with many other
16 types. To fix this problem, this patch adds a new type struct
17 vector_header that documents the constraints on layout of vectors
18 and pseudovectors, and helps optimizing compilers not get fooled
19 by Emacs's type punning. It also adds the macros XSETTYPED_PVECTYPE
20 XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
21 * lisp.h (XVECTOR_SIZE): New convenience macro. All previous uses of
22 XVECTOR (foo)->size replaced to use this macro, to avoid the hassle
23 of writing XVECTOR (foo)->header.size.
24 * lisp.h: Say "vectorlike header" rather than "vector header.
25 (struct vectorlike_header): Rename from struct vector_header.
26 (XVECTORLIKE_HEADER_SIZE): Renamed from XVECTOR_HEADER_SIZE.
27 All uses changed.
28 (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
29 (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
30 member.
31 (XSETPVECTYPE): Rewrite in terms of new macro.
32 (XSETPVECTYPESIZE): New macro, specifying both type and size.
33 This is a bit clearer, and further avoids the possibility of
34 undesirable aliasing.
35 (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
36 (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
37 and XVECTOR_HEADER_SIZE.
38 (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
39 since Lisp_Subr is a special case (no "next" field).
40 (ASIZE): Rewrite in terms of XVECTOR_SIZE.
41 (struct vector_header): New type.
42 (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
43 object, to help avoid aliasing.
44 (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
45 (SUBRP): Likewise, since Lisp_Subr is a special case.
46
47 * lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
48 (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
49 (struct Lisp_Hash_Table): Combine first two members into a single
50 struct vector_header member. All uses of "size" and "next" members
51 changed to be "header.size" and "header.next".
52 * buffer.h (struct buffer): Likewise.
53 * font.h (struct font_spec, struct font_entity, struct font): Likewise.
54 * frame.h (struct frame): Likewise.
55 * process.h (struct Lisp_Process): Likewise.
56 * termhooks.h (struct terminal): Likewise.
57 * window.c (struct save_window_data, struct saved_window): Likewise.
58 * window.h (struct window): Likewise.
59 * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
60 Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
61 * buffer.c (init_buffer_once): Likewise.
62 * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
63 special case.
64 * process.c (Fformat_network_address): Use local var for size,
65 for brevity.
66 * fns.c (vector): Remove; this old hack is no longer needed.
67 * bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
68
12011-04-29 Eli Zaretskii <eliz@gnu.org> 692011-04-29 Eli Zaretskii <eliz@gnu.org>
2 70
3 * w32heap.c (allocate_heap) [USE_LISP_UNION_TYPE || USE_LSB_TAG]: 71 * w32heap.c (allocate_heap) [USE_LISP_UNION_TYPE || USE_LSB_TAG]: