changeset 53582:b4eef5adebbf

(struct interval_block, struct string_block) (struct symbol_block, struct marker_block, live_string_p) (live_cons_p, live_symbol_p, live_float_p, live_misc_p): Better preserve alignment for objects in blocks. (FLOAT_BLOCK_SIZE): Adjust for possible alignment padding.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 14 Jan 2004 14:35:23 +0000
parents 78f37e5ea2f2
children 45ae41a57a36
files src/alloc.c
diffstat 1 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Wed Jan 14 14:29:48 2004 +0000
+++ b/src/alloc.c	Wed Jan 14 14:35:23 2004 +0000
@@ -1,5 +1,5 @@
 /* Storage allocation and gc for GNU Emacs Lisp interpreter.
-   Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1985,86,88,93,94,95,97,98,1999,2000,01,02,03,2004
       Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -1104,8 +1104,9 @@
 
 struct interval_block
 {
+  /* Place `intervals' first, to preserve alignment.  */
+  struct interval intervals[INTERVAL_BLOCK_SIZE];
   struct interval_block *next;
-  struct interval intervals[INTERVAL_BLOCK_SIZE];
 };
 
 /* Current interval block.  Its `next' pointer points to older
@@ -1343,8 +1344,9 @@
 
 struct string_block
 {
+  /* Place `strings' first, to preserve alignment.  */
+  struct Lisp_String strings[STRING_BLOCK_SIZE];
   struct string_block *next;
-  struct Lisp_String strings[STRING_BLOCK_SIZE];
 };
 
 /* Head and tail of the list of sblock structures holding Lisp string
@@ -2125,8 +2127,10 @@
    by GC are put on a free list to be reallocated before allocating
    any new float cells from the latest float_block.  */
 
-#define FLOAT_BLOCK_SIZE \
-  (((BLOCK_BYTES - sizeof (struct float_block *)) * CHAR_BIT) \
+#define FLOAT_BLOCK_SIZE					\
+  (((BLOCK_BYTES - sizeof (struct float_block *)		\
+     /* The compiler might add padding at the end.  */		\
+     - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \
    / (sizeof (struct Lisp_Float) * CHAR_BIT + 1))
 
 #define GETMARKBIT(block,n)				\
@@ -2753,8 +2757,9 @@
 
 struct symbol_block
 {
+  /* Place `symbols' first, to preserve alignment.  */
+  struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE];
   struct symbol_block *next;
-  struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE];
 };
 
 /* Current symbol block and index of first unused Lisp_Symbol
@@ -2845,8 +2850,9 @@
 
 struct marker_block
 {
+  /* Place `markers' first, to preserve alignment.  */
+  union Lisp_Misc markers[MARKER_BLOCK_SIZE];
   struct marker_block *next;
-  union Lisp_Misc markers[MARKER_BLOCK_SIZE];
 };
 
 struct marker_block *marker_block;
@@ -3427,6 +3433,7 @@
 	 must not be on the free-list.  */
       return (offset >= 0
 	      && offset % sizeof b->strings[0] == 0
+	      && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0])
 	      && ((struct Lisp_String *) p)->data != NULL);
     }
   else
@@ -3451,8 +3458,8 @@
 	 one of the unused cells in the current cons block,
 	 and not be on the free-list.  */
       return (offset >= 0
+	      && offset % sizeof b->conses[0] == 0
 	      && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
-	      && offset % sizeof b->conses[0] == 0
 	      && (b != cons_block
 		  || offset / sizeof b->conses[0] < cons_block_index)
 	      && !EQ (((struct Lisp_Cons *) p)->car, Vdead));
@@ -3480,6 +3487,7 @@
 	 and not be on the free-list.  */
       return (offset >= 0
 	      && offset % sizeof b->symbols[0] == 0
+	      && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0])
 	      && (b != symbol_block
 		  || offset / sizeof b->symbols[0] < symbol_block_index)
 	      && !EQ (((struct Lisp_Symbol *) p)->function, Vdead));
@@ -3505,8 +3513,8 @@
       /* P must point to the start of a Lisp_Float and not be
 	 one of the unused cells in the current float block.  */
       return (offset >= 0
+	      && offset % sizeof b->floats[0] == 0
 	      && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
-	      && offset % sizeof b->floats[0] == 0
 	      && (b != float_block
 		  || offset / sizeof b->floats[0] < float_block_index));
     }
@@ -3533,6 +3541,7 @@
 	 and not be on the free-list.  */
       return (offset >= 0
 	      && offset % sizeof b->markers[0] == 0
+	      && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0])
 	      && (b != marker_block
 		  || offset / sizeof b->markers[0] < marker_block_index)
 	      && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free);