diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c index 616e264fbf1..4afcab2c20a 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. |
| @@ -599,6 +599,7 @@ lisp_malloc (nbytes, type) | |||
| 599 | 599 | ||
| 600 | val = (void *) malloc (nbytes); | 600 | val = (void *) malloc (nbytes); |
| 601 | 601 | ||
| 602 | #ifndef USE_LSB_TAG | ||
| 602 | /* If the memory just allocated cannot be addressed thru a Lisp | 603 | /* If the memory just allocated cannot be addressed thru a Lisp |
| 603 | object's pointer, and it needs to be, | 604 | object's pointer, and it needs to be, |
| 604 | that's equivalent to running out of memory. */ | 605 | that's equivalent to running out of memory. */ |
| @@ -613,6 +614,7 @@ lisp_malloc (nbytes, type) | |||
| 613 | val = 0; | 614 | val = 0; |
| 614 | } | 615 | } |
| 615 | } | 616 | } |
| 617 | #endif | ||
| 616 | 618 | ||
| 617 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK | 619 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
| 618 | if (val && type != MEM_TYPE_NON_LISP) | 620 | if (val && type != MEM_TYPE_NON_LISP) |
| @@ -773,6 +775,7 @@ lisp_align_malloc (nbytes, type) | |||
| 773 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 775 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 774 | #endif | 776 | #endif |
| 775 | 777 | ||
| 778 | #ifndef USE_LSB_TAG | ||
| 776 | /* If the memory just allocated cannot be addressed thru a Lisp | 779 | /* If the memory just allocated cannot be addressed thru a Lisp |
| 777 | object's pointer, and it needs to be, that's equivalent to | 780 | object's pointer, and it needs to be, that's equivalent to |
| 778 | running out of memory. */ | 781 | running out of memory. */ |
| @@ -789,6 +792,7 @@ lisp_align_malloc (nbytes, type) | |||
| 789 | memory_full (); | 792 | memory_full (); |
| 790 | } | 793 | } |
| 791 | } | 794 | } |
| 795 | #endif | ||
| 792 | 796 | ||
| 793 | /* Initialize the blocks and put them on the free list. | 797 | /* Initialize the blocks and put them on the free list. |
| 794 | Is `base' was not properly aligned, we can't use the last block. */ | 798 | Is `base' was not properly aligned, we can't use the last block. */ |
| @@ -1105,8 +1109,9 @@ uninterrupt_malloc () | |||
| 1105 | 1109 | ||
| 1106 | struct interval_block | 1110 | struct interval_block |
| 1107 | { | 1111 | { |
| 1108 | struct interval_block *next; | 1112 | /* Place `intervals' first, to preserve alignment. */ |
| 1109 | struct interval intervals[INTERVAL_BLOCK_SIZE]; | 1113 | struct interval intervals[INTERVAL_BLOCK_SIZE]; |
| 1114 | struct interval_block *next; | ||
| 1110 | }; | 1115 | }; |
| 1111 | 1116 | ||
| 1112 | /* Current interval block. Its `next' pointer points to older | 1117 | /* Current interval block. Its `next' pointer points to older |
| @@ -1344,8 +1349,9 @@ struct sblock | |||
| 1344 | 1349 | ||
| 1345 | struct string_block | 1350 | struct string_block |
| 1346 | { | 1351 | { |
| 1347 | struct string_block *next; | 1352 | /* Place `strings' first, to preserve alignment. */ |
| 1348 | struct Lisp_String strings[STRING_BLOCK_SIZE]; | 1353 | struct Lisp_String strings[STRING_BLOCK_SIZE]; |
| 1354 | struct string_block *next; | ||
| 1349 | }; | 1355 | }; |
| 1350 | 1356 | ||
| 1351 | /* Head and tail of the list of sblock structures holding Lisp string | 1357 | /* Head and tail of the list of sblock structures holding Lisp string |
| @@ -2126,8 +2132,10 @@ make_uninit_multibyte_string (nchars, nbytes) | |||
| 2126 | by GC are put on a free list to be reallocated before allocating | 2132 | by GC are put on a free list to be reallocated before allocating |
| 2127 | any new float cells from the latest float_block. */ | 2133 | any new float cells from the latest float_block. */ |
| 2128 | 2134 | ||
| 2129 | #define FLOAT_BLOCK_SIZE \ | 2135 | #define FLOAT_BLOCK_SIZE \ |
| 2130 | (((BLOCK_BYTES - sizeof (struct float_block *)) * CHAR_BIT) \ | 2136 | (((BLOCK_BYTES - sizeof (struct float_block *) \ |
| 2137 | /* The compiler might add padding at the end. */ \ | ||
| 2138 | - (sizeof (struct Lisp_Float) - sizeof (int))) * CHAR_BIT) \ | ||
| 2131 | / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) | 2139 | / (sizeof (struct Lisp_Float) * CHAR_BIT + 1)) |
| 2132 | 2140 | ||
| 2133 | #define GETMARKBIT(block,n) \ | 2141 | #define GETMARKBIT(block,n) \ |
| @@ -2754,8 +2762,9 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT | |||
| 2754 | 2762 | ||
| 2755 | struct symbol_block | 2763 | struct symbol_block |
| 2756 | { | 2764 | { |
| 2757 | struct symbol_block *next; | 2765 | /* Place `symbols' first, to preserve alignment. */ |
| 2758 | struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; | 2766 | struct Lisp_Symbol symbols[SYMBOL_BLOCK_SIZE]; |
| 2767 | struct symbol_block *next; | ||
| 2759 | }; | 2768 | }; |
| 2760 | 2769 | ||
| 2761 | /* Current symbol block and index of first unused Lisp_Symbol | 2770 | /* Current symbol block and index of first unused Lisp_Symbol |
| @@ -2846,8 +2855,9 @@ Its value and function definition are void, and its property list is nil. */) | |||
| 2846 | 2855 | ||
| 2847 | struct marker_block | 2856 | struct marker_block |
| 2848 | { | 2857 | { |
| 2849 | struct marker_block *next; | 2858 | /* Place `markers' first, to preserve alignment. */ |
| 2850 | union Lisp_Misc markers[MARKER_BLOCK_SIZE]; | 2859 | union Lisp_Misc markers[MARKER_BLOCK_SIZE]; |
| 2860 | struct marker_block *next; | ||
| 2851 | }; | 2861 | }; |
| 2852 | 2862 | ||
| 2853 | struct marker_block *marker_block; | 2863 | struct marker_block *marker_block; |
| @@ -3428,6 +3438,7 @@ live_string_p (m, p) | |||
| 3428 | must not be on the free-list. */ | 3438 | must not be on the free-list. */ |
| 3429 | return (offset >= 0 | 3439 | return (offset >= 0 |
| 3430 | && offset % sizeof b->strings[0] == 0 | 3440 | && offset % sizeof b->strings[0] == 0 |
| 3441 | && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0]) | ||
| 3431 | && ((struct Lisp_String *) p)->data != NULL); | 3442 | && ((struct Lisp_String *) p)->data != NULL); |
| 3432 | } | 3443 | } |
| 3433 | else | 3444 | else |
| @@ -3452,8 +3463,8 @@ live_cons_p (m, p) | |||
| 3452 | one of the unused cells in the current cons block, | 3463 | one of the unused cells in the current cons block, |
| 3453 | and not be on the free-list. */ | 3464 | and not be on the free-list. */ |
| 3454 | return (offset >= 0 | 3465 | return (offset >= 0 |
| 3455 | && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) | ||
| 3456 | && offset % sizeof b->conses[0] == 0 | 3466 | && offset % sizeof b->conses[0] == 0 |
| 3467 | && offset < (CONS_BLOCK_SIZE * sizeof b->conses[0]) | ||
| 3457 | && (b != cons_block | 3468 | && (b != cons_block |
| 3458 | || offset / sizeof b->conses[0] < cons_block_index) | 3469 | || offset / sizeof b->conses[0] < cons_block_index) |
| 3459 | && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); | 3470 | && !EQ (((struct Lisp_Cons *) p)->car, Vdead)); |
| @@ -3481,6 +3492,7 @@ live_symbol_p (m, p) | |||
| 3481 | and not be on the free-list. */ | 3492 | and not be on the free-list. */ |
| 3482 | return (offset >= 0 | 3493 | return (offset >= 0 |
| 3483 | && offset % sizeof b->symbols[0] == 0 | 3494 | && offset % sizeof b->symbols[0] == 0 |
| 3495 | && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) | ||
| 3484 | && (b != symbol_block | 3496 | && (b != symbol_block |
| 3485 | || offset / sizeof b->symbols[0] < symbol_block_index) | 3497 | || offset / sizeof b->symbols[0] < symbol_block_index) |
| 3486 | && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); | 3498 | && !EQ (((struct Lisp_Symbol *) p)->function, Vdead)); |
| @@ -3506,8 +3518,8 @@ live_float_p (m, p) | |||
| 3506 | /* P must point to the start of a Lisp_Float and not be | 3518 | /* P must point to the start of a Lisp_Float and not be |
| 3507 | one of the unused cells in the current float block. */ | 3519 | one of the unused cells in the current float block. */ |
| 3508 | return (offset >= 0 | 3520 | return (offset >= 0 |
| 3509 | && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) | ||
| 3510 | && offset % sizeof b->floats[0] == 0 | 3521 | && offset % sizeof b->floats[0] == 0 |
| 3522 | && offset < (FLOAT_BLOCK_SIZE * sizeof b->floats[0]) | ||
| 3511 | && (b != float_block | 3523 | && (b != float_block |
| 3512 | || offset / sizeof b->floats[0] < float_block_index)); | 3524 | || offset / sizeof b->floats[0] < float_block_index)); |
| 3513 | } | 3525 | } |
| @@ -3534,6 +3546,7 @@ live_misc_p (m, p) | |||
| 3534 | and not be on the free-list. */ | 3546 | and not be on the free-list. */ |
| 3535 | return (offset >= 0 | 3547 | return (offset >= 0 |
| 3536 | && offset % sizeof b->markers[0] == 0 | 3548 | && offset % sizeof b->markers[0] == 0 |
| 3549 | && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0]) | ||
| 3537 | && (b != marker_block | 3550 | && (b != marker_block |
| 3538 | || offset / sizeof b->markers[0] < marker_block_index) | 3551 | || offset / sizeof b->markers[0] < marker_block_index) |
| 3539 | && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); | 3552 | && ((union Lisp_Misc *) p)->u_marker.type != Lisp_Misc_Free); |
| @@ -4068,6 +4081,9 @@ pure_alloc (size, type) | |||
| 4068 | int type; | 4081 | int type; |
| 4069 | { | 4082 | { |
| 4070 | POINTER_TYPE *result; | 4083 | POINTER_TYPE *result; |
| 4084 | #ifdef USE_LSB_TAG | ||
| 4085 | size_t alignment = (1 << GCTYPEBITS); | ||
| 4086 | #else | ||
| 4071 | size_t alignment = sizeof (EMACS_INT); | 4087 | size_t alignment = sizeof (EMACS_INT); |
| 4072 | 4088 | ||
| 4073 | /* Give Lisp_Floats an extra alignment. */ | 4089 | /* Give Lisp_Floats an extra alignment. */ |
| @@ -4079,6 +4095,7 @@ pure_alloc (size, type) | |||
| 4079 | alignment = sizeof (struct Lisp_Float); | 4095 | alignment = sizeof (struct Lisp_Float); |
| 4080 | #endif | 4096 | #endif |
| 4081 | } | 4097 | } |
| 4098 | #endif | ||
| 4082 | 4099 | ||
| 4083 | again: | 4100 | again: |
| 4084 | result = ALIGN (purebeg + pure_bytes_used, alignment); | 4101 | result = ALIGN (purebeg + pure_bytes_used, alignment); |