diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/src/alloc.c b/src/alloc.c index 7051af9b99c..1223f0bc13d 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -533,7 +533,7 @@ buffer_memory_full (ptrdiff_t nbytes) | |||
| 533 | }, \ | 533 | }, \ |
| 534 | c) | 534 | c) |
| 535 | 535 | ||
| 536 | #ifdef USE_LSB_TAG | 536 | #if USE_LSB_TAG |
| 537 | # define XMALLOC_HEADER_ALIGNMENT \ | 537 | # define XMALLOC_HEADER_ALIGNMENT \ |
| 538 | COMMON_MULTIPLE (1 << GCTYPEBITS, XMALLOC_BASE_ALIGNMENT) | 538 | COMMON_MULTIPLE (1 << GCTYPEBITS, XMALLOC_BASE_ALIGNMENT) |
| 539 | #else | 539 | #else |
| @@ -893,8 +893,8 @@ safe_alloca_unwind (Lisp_Object arg) | |||
| 893 | number of bytes to allocate, TYPE describes the intended use of the | 893 | number of bytes to allocate, TYPE describes the intended use of the |
| 894 | allocated memory block (for strings, for conses, ...). */ | 894 | allocated memory block (for strings, for conses, ...). */ |
| 895 | 895 | ||
| 896 | #ifndef USE_LSB_TAG | 896 | #if ! USE_LSB_TAG |
| 897 | static void *lisp_malloc_loser; | 897 | void *lisp_malloc_loser EXTERNALLY_VISIBLE; |
| 898 | #endif | 898 | #endif |
| 899 | 899 | ||
| 900 | static void * | 900 | static void * |
| @@ -910,7 +910,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) | |||
| 910 | 910 | ||
| 911 | val = (void *) malloc (nbytes); | 911 | val = (void *) malloc (nbytes); |
| 912 | 912 | ||
| 913 | #ifndef USE_LSB_TAG | 913 | #if ! USE_LSB_TAG |
| 914 | /* If the memory just allocated cannot be addressed thru a Lisp | 914 | /* If the memory just allocated cannot be addressed thru a Lisp |
| 915 | object's pointer, and it needs to be, | 915 | object's pointer, and it needs to be, |
| 916 | that's equivalent to running out of memory. */ | 916 | that's equivalent to running out of memory. */ |
| @@ -1091,7 +1091,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 1091 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 1091 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 1092 | #endif | 1092 | #endif |
| 1093 | 1093 | ||
| 1094 | #ifndef USE_LSB_TAG | 1094 | #if ! USE_LSB_TAG |
| 1095 | /* If the memory just allocated cannot be addressed thru a Lisp | 1095 | /* If the memory just allocated cannot be addressed thru a Lisp |
| 1096 | object's pointer, and it needs to be, that's equivalent to | 1096 | object's pointer, and it needs to be, that's equivalent to |
| 1097 | running out of memory. */ | 1097 | running out of memory. */ |
| @@ -1584,20 +1584,6 @@ mark_interval_tree (register INTERVAL tree) | |||
| 1584 | if (! NULL_INTERVAL_P (i)) \ | 1584 | if (! NULL_INTERVAL_P (i)) \ |
| 1585 | (i) = balance_intervals (i); \ | 1585 | (i) = balance_intervals (i); \ |
| 1586 | } while (0) | 1586 | } while (0) |
| 1587 | |||
| 1588 | |||
| 1589 | /* Number support. If USE_LISP_UNION_TYPE is in effect, we | ||
| 1590 | can't create number objects in macros. */ | ||
| 1591 | #ifndef make_number | ||
| 1592 | Lisp_Object | ||
| 1593 | make_number (EMACS_INT n) | ||
| 1594 | { | ||
| 1595 | Lisp_Object obj; | ||
| 1596 | obj.s.val = n; | ||
| 1597 | obj.s.type = Lisp_Int; | ||
| 1598 | return obj; | ||
| 1599 | } | ||
| 1600 | #endif | ||
| 1601 | 1587 | ||
| 1602 | /* Convert the pointer-sized word P to EMACS_INT while preserving its | 1588 | /* Convert the pointer-sized word P to EMACS_INT while preserving its |
| 1603 | type and ptr fields. */ | 1589 | type and ptr fields. */ |
| @@ -2943,18 +2929,13 @@ enum | |||
| 2943 | header_size = offsetof (struct Lisp_Vector, contents), | 2929 | header_size = offsetof (struct Lisp_Vector, contents), |
| 2944 | word_size = sizeof (Lisp_Object), | 2930 | word_size = sizeof (Lisp_Object), |
| 2945 | roundup_size = COMMON_MULTIPLE (sizeof (Lisp_Object), | 2931 | roundup_size = COMMON_MULTIPLE (sizeof (Lisp_Object), |
| 2946 | #ifdef USE_LSB_TAG | 2932 | USE_LSB_TAG ? 1 << GCTYPEBITS : 1) |
| 2947 | 8 /* Helps to maintain alignment constraints imposed by | ||
| 2948 | assumption that least 3 bits of pointers are always 0. */ | ||
| 2949 | #else | ||
| 2950 | 1 /* If alignment doesn't matter, should round up | ||
| 2951 | to sizeof (Lisp_Object) at least. */ | ||
| 2952 | #endif | ||
| 2953 | ) | ||
| 2954 | }; | 2933 | }; |
| 2955 | 2934 | ||
| 2956 | /* Round up X to nearest mult-of-ROUNDUP_SIZE, | 2935 | /* ROUNDUP_SIZE must be a power of 2. */ |
| 2957 | assuming ROUNDUP_SIZE is a power of 2. */ | 2936 | verify ((roundup_size & (roundup_size - 1)) == 0); |
| 2937 | |||
| 2938 | /* Round up X to nearest mult-of-ROUNDUP_SIZE. */ | ||
| 2958 | 2939 | ||
| 2959 | #define vroundup(x) (((x) + (roundup_size - 1)) & ~(roundup_size - 1)) | 2940 | #define vroundup(x) (((x) + (roundup_size - 1)) & ~(roundup_size - 1)) |
| 2960 | 2941 | ||
| @@ -3171,7 +3152,7 @@ sweep_vectors (void) | |||
| 3171 | == VECTOR_FREE_LIST_FLAG) | 3152 | == VECTOR_FREE_LIST_FLAG) |
| 3172 | vector->header.next.nbytes = | 3153 | vector->header.next.nbytes = |
| 3173 | vector->header.size & (VECTOR_BLOCK_SIZE - 1); | 3154 | vector->header.size & (VECTOR_BLOCK_SIZE - 1); |
| 3174 | 3155 | ||
| 3175 | next = ADVANCE (vector, vector->header.next.nbytes); | 3156 | next = ADVANCE (vector, vector->header.next.nbytes); |
| 3176 | 3157 | ||
| 3177 | /* While NEXT is not marked, try to coalesce with VECTOR, | 3158 | /* While NEXT is not marked, try to coalesce with VECTOR, |
| @@ -3189,7 +3170,7 @@ sweep_vectors (void) | |||
| 3189 | vector->header.next.nbytes += nbytes; | 3170 | vector->header.next.nbytes += nbytes; |
| 3190 | next = ADVANCE (next, nbytes); | 3171 | next = ADVANCE (next, nbytes); |
| 3191 | } | 3172 | } |
| 3192 | 3173 | ||
| 3193 | eassert (vector->header.next.nbytes % roundup_size == 0); | 3174 | eassert (vector->header.next.nbytes % roundup_size == 0); |
| 3194 | 3175 | ||
| 3195 | if (vector == (struct Lisp_Vector *) block->data | 3176 | if (vector == (struct Lisp_Vector *) block->data |
| @@ -3468,7 +3449,7 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT | |||
| 3468 | union aligned_Lisp_Symbol | 3449 | union aligned_Lisp_Symbol |
| 3469 | { | 3450 | { |
| 3470 | struct Lisp_Symbol s; | 3451 | struct Lisp_Symbol s; |
| 3471 | #ifdef USE_LSB_TAG | 3452 | #if USE_LSB_TAG |
| 3472 | unsigned char c[(sizeof (struct Lisp_Symbol) + (1 << GCTYPEBITS) - 1) | 3453 | unsigned char c[(sizeof (struct Lisp_Symbol) + (1 << GCTYPEBITS) - 1) |
| 3473 | & -(1 << GCTYPEBITS)]; | 3454 | & -(1 << GCTYPEBITS)]; |
| 3474 | #endif | 3455 | #endif |
| @@ -3574,7 +3555,7 @@ Its value and function definition are void, and its property list is nil. */) | |||
| 3574 | union aligned_Lisp_Misc | 3555 | union aligned_Lisp_Misc |
| 3575 | { | 3556 | { |
| 3576 | union Lisp_Misc m; | 3557 | union Lisp_Misc m; |
| 3577 | #ifdef USE_LSB_TAG | 3558 | #if USE_LSB_TAG |
| 3578 | unsigned char c[(sizeof (union Lisp_Misc) + (1 << GCTYPEBITS) - 1) | 3559 | unsigned char c[(sizeof (union Lisp_Misc) + (1 << GCTYPEBITS) - 1) |
| 3579 | & -(1 << GCTYPEBITS)]; | 3560 | & -(1 << GCTYPEBITS)]; |
| 3580 | #endif | 3561 | #endif |
| @@ -4556,14 +4537,10 @@ mark_maybe_pointer (void *p) | |||
| 4556 | { | 4537 | { |
| 4557 | struct mem_node *m; | 4538 | struct mem_node *m; |
| 4558 | 4539 | ||
| 4559 | /* Quickly rule out some values which can't point to Lisp data. */ | 4540 | /* Quickly rule out some values which can't point to Lisp data. |
| 4560 | if ((intptr_t) p % | 4541 | USE_LSB_TAG needs Lisp data to be aligned on multiples of 1 << GCTYPEBITS. |
| 4561 | #ifdef USE_LSB_TAG | 4542 | Otherwise, assume that Lisp data is aligned on even addresses. */ |
| 4562 | 8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8. */ | 4543 | if ((intptr_t) p % (USE_LSB_TAG ? 1 << GCTYPEBITS : 2)) |
| 4563 | #else | ||
| 4564 | 2 /* We assume that Lisp data is aligned on even addresses. */ | ||
| 4565 | #endif | ||
| 4566 | ) | ||
| 4567 | return; | 4544 | return; |
| 4568 | 4545 | ||
| 4569 | m = mem_find (p); | 4546 | m = mem_find (p); |
| @@ -4639,8 +4616,8 @@ mark_maybe_pointer (void *p) | |||
| 4639 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. | 4616 | wider than a pointer might allocate a Lisp_Object in non-adjacent halves. |
| 4640 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should | 4617 | If USE_LSB_TAG, the bottom half is not a valid pointer, but it should |
| 4641 | suffice to widen it to to a Lisp_Object and check it that way. */ | 4618 | suffice to widen it to to a Lisp_Object and check it that way. */ |
| 4642 | #if defined USE_LSB_TAG || VAL_MAX < UINTPTR_MAX | 4619 | #if USE_LSB_TAG || VAL_MAX < UINTPTR_MAX |
| 4643 | # if !defined USE_LSB_TAG && VAL_MAX < UINTPTR_MAX >> GCTYPEBITS | 4620 | # if !USE_LSB_TAG && VAL_MAX < UINTPTR_MAX >> GCTYPEBITS |
| 4644 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer | 4621 | /* If tag bits straddle pointer-word boundaries, neither mark_maybe_pointer |
| 4645 | nor mark_maybe_object can follow the pointers. This should not occur on | 4622 | nor mark_maybe_object can follow the pointers. This should not occur on |
| 4646 | any practical porting target. */ | 4623 | any practical porting target. */ |
| @@ -5069,7 +5046,7 @@ static void * | |||
| 5069 | pure_alloc (size_t size, int type) | 5046 | pure_alloc (size_t size, int type) |
| 5070 | { | 5047 | { |
| 5071 | void *result; | 5048 | void *result; |
| 5072 | #ifdef USE_LSB_TAG | 5049 | #if USE_LSB_TAG |
| 5073 | size_t alignment = (1 << GCTYPEBITS); | 5050 | size_t alignment = (1 << GCTYPEBITS); |
| 5074 | #else | 5051 | #else |
| 5075 | size_t alignment = sizeof (EMACS_INT); | 5052 | size_t alignment = sizeof (EMACS_INT); |