(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.
This commit is contained in:
parent
2fcad71e3e
commit
d05b383acd
1 changed files with 18 additions and 9 deletions
27
src/alloc.c
27
src/alloc.c
|
@ -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 @@ uninterrupt_malloc ()
|
|||
|
||||
struct interval_block
|
||||
{
|
||||
struct interval_block *next;
|
||||
/* Place `intervals' first, to preserve alignment. */
|
||||
struct interval intervals[INTERVAL_BLOCK_SIZE];
|
||||
struct interval_block *next;
|
||||
};
|
||||
|
||||
/* Current interval block. Its `next' pointer points to older
|
||||
|
@ -1343,8 +1344,9 @@ struct sblock
|
|||
|
||||
struct string_block
|
||||
{
|
||||
struct string_block *next;
|
||||
/* Place `strings' first, to preserve alignment. */
|
||||
struct Lisp_String strings[STRING_BLOCK_SIZE];
|
||||
struct string_block *next;
|
||||
};
|
||||
|
||||
/* Head and tail of the list of sblock structures holding Lisp string
|
||||
|
@ -2125,8 +2127,10 @@ make_uninit_multibyte_string (nchars, nbytes)
|
|||
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 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
|
|||
|
||||
struct symbol_block
|
||||
{
|
||||
struct symbol_block *next;
|
||||
/* Place `symbols' first, to preserve alignment. */
|
||||
struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE];
|
||||
struct symbol_block *next;
|
||||
};
|
||||
|
||||
/* Current symbol block and index of first unused Lisp_Symbol
|
||||
|
@ -2845,8 +2850,9 @@ Its value and function definition are void, and its property list is nil. */)
|
|||
|
||||
struct marker_block
|
||||
{
|
||||
struct marker_block *next;
|
||||
/* Place `markers' first, to preserve alignment. */
|
||||
union Lisp_Misc markers[MARKER_BLOCK_SIZE];
|
||||
struct marker_block *next;
|
||||
};
|
||||
|
||||
struct marker_block *marker_block;
|
||||
|
@ -3427,6 +3433,7 @@ live_string_p (m, p)
|
|||
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 @@ live_cons_p (m, p)
|
|||
one of the unused cells in the current cons block,
|
||||
and not be on the free-list. */
|
||||
return (offset >= 0
|
||||
&& offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
|
||||
&& offset % sizeof b->conses[0] == 0
|
||||
&& offset < (CONS_BLOCK_SIZE * sizeof b->conses[0])
|
||||
&& (b != cons_block
|
||||
|| offset / sizeof b->conses[0] < cons_block_index)
|
||||
&& !EQ (((struct Lisp_Cons *) p)->car, Vdead));
|
||||
|
@ -3480,6 +3487,7 @@ live_symbol_p (m, p)
|
|||
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 @@ live_float_p (m, p)
|
|||
/* 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 < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
|
||||
&& offset % sizeof b->floats[0] == 0
|
||||
&& offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0])
|
||||
&& (b != float_block
|
||||
|| offset / sizeof b->floats[0] < float_block_index));
|
||||
}
|
||||
|
@ -3533,6 +3541,7 @@ live_misc_p (m, p)
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue