diff options
| author | Stefan Monnier | 2004-01-14 14:35:23 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-01-14 14:35:23 +0000 |
| commit | d05b383acd3e295ae429ca5f72467e5f82e5df95 (patch) | |
| tree | e9683b4b0249ad61cfd6c2a6172ec23933f02708 /src | |
| parent | 2fcad71e3ebcc62140421d04bb4823c800f3042e (diff) | |
| download | emacs-d05b383acd3e295ae429ca5f72467e5f82e5df95.tar.gz emacs-d05b383acd3e295ae429ca5f72467e5f82e5df95.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c index 91fade83609..484478ac3dd 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Storage allocation and gc for GNU Emacs Lisp interpreter. | 1 | /* Storage allocation and gc for GNU Emacs Lisp interpreter. |
| 2 | Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001, 2002, 2003 | 2 | Copyright (C) 1985,86,88,93,94,95,97,98,1999,2000,01,02,03,2004 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -1104,8 +1104,9 @@ uninterrupt_malloc () | |||
| 1104 | 1104 | ||
| 1105 | struct interval_block | 1105 | struct interval_block |
| 1106 | { | 1106 | { |
| 1107 | struct interval_block *next; | 1107 | /* Place `intervals' first, to preserve alignment. */ |
| 1108 | struct interval intervals[INTERVAL_BLOCK_SIZE]; | 1108 | struct interval intervals[INTERVAL_BLOCK_SIZE]; |
| 1109 | struct interval_block *next; | ||
| 1109 | }; | 1110 | }; |
| 1110 | 1111 | ||
| 1111 | /* Current interval block. Its `next' pointer points to older | 1112 | /* Current interval block. Its `next' pointer points to older |
| @@ -1343,8 +1344,9 @@ struct sblock | |||
| 1343 | 1344 | ||
| 1344 | struct string_block | 1345 | struct string_block |
| 1345 | { | 1346 | { |
| 1346 | struct string_block *next; | 1347 | /* Place `strings' first, to preserve alignment. */ |
| 1347 | struct Lisp_String strings[STRING_BLOCK_SIZE]; | 1348 | struct Lisp_String strings[STRING_BLOCK_SIZE]; |
| 1349 | struct string_block *next; | ||
| 1348 | }; | 1350 | }; |
| 1349 | 1351 | ||
| 1350 | /* Head and tail of the list of sblock structures holding Lisp string | 1352 | /* Head and tail of the list of sblock structures holding Lisp string |
| @@ -2125,8 +2127,10 @@ make_uninit_multibyte_string (nchars, nbytes) | |||
| 2125 | by GC are put on a free list to be reallocated before allocating | 2127 | by GC are put on a free list to be reallocated before allocating |
| 2126 | any new float cells from the latest float_block. */ | 2128 | any new float cells from the latest float_block. */ |
| 2127 | 2129 | ||
| 2128 | #define FLOAT_BLOCK_SIZE \ | 2130 | #define FLOAT_BLOCK_SIZE \ |
| 2129 | (((BLOCK_BYTES - sizeof (struct float_block *)) * CHAR_BIT) \ | 2131 | (((BLOCK_BYTES - sizeof (struct float_block *) \ |
| 2132 | /* The compiler might add padding at the end. */ \ | ||
| 2133 | - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \ | ||
| 2130 | / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) | 2134 | / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) |
| 2131 | 2135 | ||
| 2132 | #define GETMARKBIT(block,n) \ | 2136 | #define GETMARKBIT(block,n) \ |
| @@ -2753,8 +2757,9 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT | |||
| 2753 | 2757 | ||
| 2754 | struct symbol_block | 2758 | struct symbol_block |
| 2755 | { | 2759 | { |
| 2756 | struct symbol_block *next; | 2760 | /* Place `symbols' first, to preserve alignment. */ |
| 2757 | struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; | 2761 | struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; |
| 2762 | struct symbol_block *next; | ||
| 2758 | }; | 2763 | }; |
| 2759 | 2764 | ||
| 2760 | /* Current symbol block and index of first unused Lisp_Symbol | 2765 | /* 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. */) | |||
| 2845 | 2850 | ||
| 2846 | struct marker_block | 2851 | struct marker_block |
| 2847 | { | 2852 | { |
| 2848 | struct marker_block *next; | 2853 | /* Place `markers' first, to preserve alignment. */ |
| 2849 | union Lisp_Misc markers[MARKER_BLOCK_SIZE]; | 2854 | union Lisp_Misc markers[MARKER_BLOCK_SIZE]; |
| 2855 | struct marker_block *next; | ||
| 2850 | }; | 2856 | }; |
| 2851 | 2857 | ||
| 2852 | struct marker_block *marker_block; | 2858 | struct marker_block *marker_block; |
| @@ -3427,6 +3433,7 @@ live_string_p (m, p) | |||
| 3427 | must not be on the free-list. */ | 3433 | must not be on the free-list. */ |
| 3428 | return (offset >= 0 | 3434 | return (offset >= 0 |
| 3429 | && offset % sizeof b->strings[0] == 0 | 3435 | && offset % sizeof b->strings[0] == 0 |
| 3436 | && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0]) | ||
| 3430 | && ((struct Lisp_String *) p)->data != NULL); | 3437 | && ((struct Lisp_String *) p)->data != NULL); |
| 3431 | } | 3438 | } |
| 3432 | else | 3439 | else |
| @@ -3451,8 +3458,8 @@ live_cons_p (m, p) | |||
| 3451 | one of the unused cells in the current cons block, | 3458 | one of the unused cells in the current cons block, |
| 3452 | and not be on the free-list. */ | 3459 | and not be on the free-list. */ |
| 3453 | return (offset >= 0 | 3460 | return (offset >= 0 |
| 3454 | && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) | ||
| 3455 | && offset % sizeof b->conses[0] == 0 | 3461 | && offset % sizeof b->conses[0] == 0 |
| 3462 | && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) | ||
| 3456 | && (b != cons_block | 3463 | && (b != cons_block |
| 3457 | || offset / sizeof b->conses[0] < cons_block_index) | 3464 | || offset / sizeof b->conses[0] < cons_block_index) |
| 3458 | && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); | 3465 | && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); |
| @@ -3480,6 +3487,7 @@ live_symbol_p (m, p) | |||
| 3480 | and not be on the free-list. */ | 3487 | and not be on the free-list. */ |
| 3481 | return (offset >= 0 | 3488 | return (offset >= 0 |
| 3482 | && offset % sizeof b->symbols[0] == 0 | 3489 | && offset % sizeof b->symbols[0] == 0 |
| 3490 | && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) | ||
| 3483 | && (b != symbol_block | 3491 | && (b != symbol_block |
| 3484 | || offset / sizeof b->symbols[0] < symbol_block_index) | 3492 | || offset / sizeof b->symbols[0] < symbol_block_index) |
| 3485 | && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); | 3493 | && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); |
| @@ -3505,8 +3513,8 @@ live_float_p (m, p) | |||
| 3505 | /* P must point to the start of a Lisp_Float and not be | 3513 | /* P must point to the start of a Lisp_Float and not be |
| 3506 | one of the unused cells in the current float block. */ | 3514 | one of the unused cells in the current float block. */ |
| 3507 | return (offset >= 0 | 3515 | return (offset >= 0 |
| 3508 | && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) | ||
| 3509 | && offset % sizeof b->floats[0] == 0 | 3516 | && offset % sizeof b->floats[0] == 0 |
| 3517 | && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) | ||
| 3510 | && (b != float_block | 3518 | && (b != float_block |
| 3511 | || offset / sizeof b->floats[0] < float_block_index)); | 3519 | || offset / sizeof b->floats[0] < float_block_index)); |
| 3512 | } | 3520 | } |
| @@ -3533,6 +3541,7 @@ live_misc_p (m, p) | |||
| 3533 | and not be on the free-list. */ | 3541 | and not be on the free-list. */ |
| 3534 | return (offset >= 0 | 3542 | return (offset >= 0 |
| 3535 | && offset % sizeof b->markers[0] == 0 | 3543 | && offset % sizeof b->markers[0] == 0 |
| 3544 | && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0]) | ||
| 3536 | && (b != marker_block | 3545 | && (b != marker_block |
| 3537 | || offset / sizeof b->markers[0] < marker_block_index) | 3546 | || offset / sizeof b->markers[0] < marker_block_index) |
| 3538 | && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); | 3547 | && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); |