diff options
| author | Joakim Verona | 2012-07-31 00:00:41 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-07-31 00:00:41 +0200 |
| commit | 55fa71b3d9bb8609ca3cbb56f92c776ad8724a69 (patch) | |
| tree | b002fe941cc8636f8bd735717e440014359839dd /src/alloc.c | |
| parent | 5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f (diff) | |
| parent | b429a4eee4e09b1ba09e17ced5091d042955d84f (diff) | |
| download | emacs-55fa71b3d9bb8609ca3cbb56f92c776ad8724a69.tar.gz emacs-55fa71b3d9bb8609ca3cbb56f92c776ad8724a69.zip | |
upstream
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 235 |
1 files changed, 110 insertions, 125 deletions
diff --git a/src/alloc.c b/src/alloc.c index ac6cb861c4d..5b2553c69cc 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -29,11 +29,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | #include <pthread.h> | 29 | #include <pthread.h> |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | /* This file is part of the core Lisp implementation, and thus must | ||
| 33 | deal with the real data structures. If the Lisp implementation is | ||
| 34 | replaced, this file likely will not be used. */ | ||
| 35 | |||
| 36 | #undef HIDE_LISP_IMPLEMENTATION | ||
| 37 | #include "lisp.h" | 32 | #include "lisp.h" |
| 38 | #include "process.h" | 33 | #include "process.h" |
| 39 | #include "intervals.h" | 34 | #include "intervals.h" |
| @@ -155,12 +150,6 @@ static pthread_mutex_t alloc_mutex; | |||
| 155 | #define VECTOR_UNMARK(V) ((V)->header.size &= ~ARRAY_MARK_FLAG) | 150 | #define VECTOR_UNMARK(V) ((V)->header.size &= ~ARRAY_MARK_FLAG) |
| 156 | #define VECTOR_MARKED_P(V) (((V)->header.size & ARRAY_MARK_FLAG) != 0) | 151 | #define VECTOR_MARKED_P(V) (((V)->header.size & ARRAY_MARK_FLAG) != 0) |
| 157 | 152 | ||
| 158 | /* Value is the number of bytes of S, a pointer to a struct Lisp_String. | ||
| 159 | Be careful during GC, because S->size contains the mark bit for | ||
| 160 | strings. */ | ||
| 161 | |||
| 162 | #define GC_STRING_BYTES(S) (STRING_BYTES (S)) | ||
| 163 | |||
| 164 | /* Default value of gc_cons_threshold (see below). */ | 153 | /* Default value of gc_cons_threshold (see below). */ |
| 165 | 154 | ||
| 166 | #define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) | 155 | #define GC_DEFAULT_THRESHOLD (100000 * sizeof (Lisp_Object)) |
| @@ -533,12 +522,7 @@ buffer_memory_full (ptrdiff_t nbytes) | |||
| 533 | hold a size_t value and (2) the header size is a multiple of the | 522 | hold a size_t value and (2) the header size is a multiple of the |
| 534 | alignment that Emacs needs for C types and for USE_LSB_TAG. */ | 523 | alignment that Emacs needs for C types and for USE_LSB_TAG. */ |
| 535 | #define XMALLOC_BASE_ALIGNMENT \ | 524 | #define XMALLOC_BASE_ALIGNMENT \ |
| 536 | offsetof ( \ | 525 | alignof (union { long double d; intmax_t i; void *p; }) |
| 537 | struct { \ | ||
| 538 | union { long double d; intmax_t i; void *p; } u; \ | ||
| 539 | char c; \ | ||
| 540 | }, \ | ||
| 541 | c) | ||
| 542 | 526 | ||
| 543 | #if USE_LSB_TAG | 527 | #if USE_LSB_TAG |
| 544 | # define XMALLOC_HEADER_ALIGNMENT \ | 528 | # define XMALLOC_HEADER_ALIGNMENT \ |
| @@ -1790,13 +1774,13 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = | |||
| 1790 | STRING_BYTES_BOUND, nor can it be so long that the size_t | 1774 | STRING_BYTES_BOUND, nor can it be so long that the size_t |
| 1791 | arithmetic in allocate_string_data would overflow while it is | 1775 | arithmetic in allocate_string_data would overflow while it is |
| 1792 | calculating a value to be passed to malloc. */ | 1776 | calculating a value to be passed to malloc. */ |
| 1793 | #define STRING_BYTES_MAX \ | 1777 | static ptrdiff_t const STRING_BYTES_MAX = |
| 1794 | min (STRING_BYTES_BOUND, \ | 1778 | min (STRING_BYTES_BOUND, |
| 1795 | ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD \ | 1779 | ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD |
| 1796 | - GC_STRING_EXTRA \ | 1780 | - GC_STRING_EXTRA |
| 1797 | - offsetof (struct sblock, first_data) \ | 1781 | - offsetof (struct sblock, first_data) |
| 1798 | - SDATA_DATA_OFFSET) \ | 1782 | - SDATA_DATA_OFFSET) |
| 1799 | & ~(sizeof (EMACS_INT) - 1))) | 1783 | & ~(sizeof (EMACS_INT) - 1))); |
| 1800 | 1784 | ||
| 1801 | /* Initialize string allocation. Called from init_alloc_once. */ | 1785 | /* Initialize string allocation. Called from init_alloc_once. */ |
| 1802 | 1786 | ||
| @@ -1812,10 +1796,8 @@ init_strings (void) | |||
| 1812 | 1796 | ||
| 1813 | static int check_string_bytes_count; | 1797 | static int check_string_bytes_count; |
| 1814 | 1798 | ||
| 1815 | #define CHECK_STRING_BYTES(S) STRING_BYTES (S) | 1799 | /* Like STRING_BYTES, but with debugging check. Can be |
| 1816 | 1800 | called during GC, so pay attention to the mark bit. */ | |
| 1817 | |||
| 1818 | /* Like GC_STRING_BYTES, but with debugging check. */ | ||
| 1819 | 1801 | ||
| 1820 | ptrdiff_t | 1802 | ptrdiff_t |
| 1821 | string_bytes (struct Lisp_String *s) | 1803 | string_bytes (struct Lisp_String *s) |
| @@ -1847,15 +1829,8 @@ check_sblock (struct sblock *b) | |||
| 1847 | 1829 | ||
| 1848 | /* Check that the string size recorded in the string is the | 1830 | /* Check that the string size recorded in the string is the |
| 1849 | same as the one recorded in the sdata structure. */ | 1831 | same as the one recorded in the sdata structure. */ |
| 1850 | if (from->string) | 1832 | nbytes = SDATA_SIZE (from->string ? string_bytes (from->string) |
| 1851 | CHECK_STRING_BYTES (from->string); | 1833 | : SDATA_NBYTES (from)); |
| 1852 | |||
| 1853 | if (from->string) | ||
| 1854 | nbytes = GC_STRING_BYTES (from->string); | ||
| 1855 | else | ||
| 1856 | nbytes = SDATA_NBYTES (from); | ||
| 1857 | |||
| 1858 | nbytes = SDATA_SIZE (nbytes); | ||
| 1859 | from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); | 1834 | from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); |
| 1860 | } | 1835 | } |
| 1861 | } | 1836 | } |
| @@ -1876,7 +1851,7 @@ check_string_bytes (int all_p) | |||
| 1876 | { | 1851 | { |
| 1877 | struct Lisp_String *s = b->first_data.string; | 1852 | struct Lisp_String *s = b->first_data.string; |
| 1878 | if (s) | 1853 | if (s) |
| 1879 | CHECK_STRING_BYTES (s); | 1854 | string_bytes (s); |
| 1880 | } | 1855 | } |
| 1881 | 1856 | ||
| 1882 | for (b = oldest_sblock; b; b = b->next) | 1857 | for (b = oldest_sblock; b; b = b->next) |
| @@ -1886,6 +1861,10 @@ check_string_bytes (int all_p) | |||
| 1886 | check_sblock (current_sblock); | 1861 | check_sblock (current_sblock); |
| 1887 | } | 1862 | } |
| 1888 | 1863 | ||
| 1864 | #else /* not GC_CHECK_STRING_BYTES */ | ||
| 1865 | |||
| 1866 | #define check_string_bytes(all) ((void) 0) | ||
| 1867 | |||
| 1889 | #endif /* GC_CHECK_STRING_BYTES */ | 1868 | #endif /* GC_CHECK_STRING_BYTES */ |
| 1890 | 1869 | ||
| 1891 | #ifdef GC_CHECK_STRING_FREE_LIST | 1870 | #ifdef GC_CHECK_STRING_FREE_LIST |
| @@ -1997,7 +1976,7 @@ allocate_string_data (struct Lisp_String *s, | |||
| 1997 | if (s->data) | 1976 | if (s->data) |
| 1998 | { | 1977 | { |
| 1999 | old_data = SDATA_OF_STRING (s); | 1978 | old_data = SDATA_OF_STRING (s); |
| 2000 | old_nbytes = GC_STRING_BYTES (s); | 1979 | old_nbytes = STRING_BYTES (s); |
| 2001 | } | 1980 | } |
| 2002 | else | 1981 | else |
| 2003 | old_data = NULL; | 1982 | old_data = NULL; |
| @@ -2131,10 +2110,10 @@ sweep_strings (void) | |||
| 2131 | how large that is. Reset the sdata's string | 2110 | how large that is. Reset the sdata's string |
| 2132 | back-pointer so that we know it's free. */ | 2111 | back-pointer so that we know it's free. */ |
| 2133 | #ifdef GC_CHECK_STRING_BYTES | 2112 | #ifdef GC_CHECK_STRING_BYTES |
| 2134 | if (GC_STRING_BYTES (s) != SDATA_NBYTES (data)) | 2113 | if (string_bytes (s) != SDATA_NBYTES (data)) |
| 2135 | abort (); | 2114 | abort (); |
| 2136 | #else | 2115 | #else |
| 2137 | data->u.nbytes = GC_STRING_BYTES (s); | 2116 | data->u.nbytes = STRING_BYTES (s); |
| 2138 | #endif | 2117 | #endif |
| 2139 | data->string = NULL; | 2118 | data->string = NULL; |
| 2140 | 2119 | ||
| @@ -2237,22 +2216,17 @@ compact_small_strings (void) | |||
| 2237 | /* Compute the next FROM here because copying below may | 2216 | /* Compute the next FROM here because copying below may |
| 2238 | overwrite data we need to compute it. */ | 2217 | overwrite data we need to compute it. */ |
| 2239 | ptrdiff_t nbytes; | 2218 | ptrdiff_t nbytes; |
| 2219 | struct Lisp_String *s = from->string; | ||
| 2240 | 2220 | ||
| 2241 | #ifdef GC_CHECK_STRING_BYTES | 2221 | #ifdef GC_CHECK_STRING_BYTES |
| 2242 | /* Check that the string size recorded in the string is the | 2222 | /* Check that the string size recorded in the string is the |
| 2243 | same as the one recorded in the sdata structure. */ | 2223 | same as the one recorded in the sdata structure. */ |
| 2244 | if (from->string | 2224 | if (s && string_bytes (s) != SDATA_NBYTES (from)) |
| 2245 | && GC_STRING_BYTES (from->string) != SDATA_NBYTES (from)) | ||
| 2246 | abort (); | 2225 | abort (); |
| 2247 | #endif /* GC_CHECK_STRING_BYTES */ | 2226 | #endif /* GC_CHECK_STRING_BYTES */ |
| 2248 | 2227 | ||
| 2249 | if (from->string) | 2228 | nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); |
| 2250 | nbytes = GC_STRING_BYTES (from->string); | 2229 | eassert (nbytes <= LARGE_STRING_BYTES); |
| 2251 | else | ||
| 2252 | nbytes = SDATA_NBYTES (from); | ||
| 2253 | |||
| 2254 | if (nbytes > LARGE_STRING_BYTES) | ||
| 2255 | abort (); | ||
| 2256 | 2230 | ||
| 2257 | nbytes = SDATA_SIZE (nbytes); | 2231 | nbytes = SDATA_SIZE (nbytes); |
| 2258 | from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); | 2232 | from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); |
| @@ -2264,8 +2238,8 @@ compact_small_strings (void) | |||
| 2264 | abort (); | 2238 | abort (); |
| 2265 | #endif | 2239 | #endif |
| 2266 | 2240 | ||
| 2267 | /* FROM->string non-null means it's alive. Copy its data. */ | 2241 | /* Non-NULL S means it's alive. Copy its data. */ |
| 2268 | if (from->string) | 2242 | if (s) |
| 2269 | { | 2243 | { |
| 2270 | /* If TB is full, proceed with the next sblock. */ | 2244 | /* If TB is full, proceed with the next sblock. */ |
| 2271 | to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); | 2245 | to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA); |
| @@ -2811,6 +2785,38 @@ list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, L | |||
| 2811 | Fcons (arg5, Qnil))))); | 2785 | Fcons (arg5, Qnil))))); |
| 2812 | } | 2786 | } |
| 2813 | 2787 | ||
| 2788 | /* Make a list of COUNT Lisp_Objects, where ARG is the | ||
| 2789 | first one. Allocate conses from pure space if TYPE | ||
| 2790 | is CONSTYPE_PURE, or allocate as usual if type is CONSTYPE_HEAP. */ | ||
| 2791 | |||
| 2792 | Lisp_Object | ||
| 2793 | listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...) | ||
| 2794 | { | ||
| 2795 | va_list ap; | ||
| 2796 | ptrdiff_t i; | ||
| 2797 | Lisp_Object val, *objp; | ||
| 2798 | |||
| 2799 | /* Change to SAFE_ALLOCA if you hit this eassert. */ | ||
| 2800 | eassert (count <= MAX_ALLOCA / sizeof (Lisp_Object)); | ||
| 2801 | |||
| 2802 | objp = alloca (count * sizeof (Lisp_Object)); | ||
| 2803 | objp[0] = arg; | ||
| 2804 | va_start (ap, arg); | ||
| 2805 | for (i = 1; i < count; i++) | ||
| 2806 | objp[i] = va_arg (ap, Lisp_Object); | ||
| 2807 | va_end (ap); | ||
| 2808 | |||
| 2809 | for (val = Qnil, i = count - 1; i >= 0; i--) | ||
| 2810 | { | ||
| 2811 | if (type == CONSTYPE_PURE) | ||
| 2812 | val = pure_cons (objp[i], val); | ||
| 2813 | else if (type == CONSTYPE_HEAP) | ||
| 2814 | val = Fcons (objp[i], val); | ||
| 2815 | else | ||
| 2816 | abort (); | ||
| 2817 | } | ||
| 2818 | return val; | ||
| 2819 | } | ||
| 2814 | 2820 | ||
| 2815 | DEFUN ("list", Flist, Slist, 0, MANY, 0, | 2821 | DEFUN ("list", Flist, Slist, 0, MANY, 0, |
| 2816 | doc: /* Return a newly created list with specified arguments as elements. | 2822 | doc: /* Return a newly created list with specified arguments as elements. |
| @@ -4620,10 +4626,10 @@ mark_maybe_pointer (void *p) | |||
| 4620 | } | 4626 | } |
| 4621 | 4627 | ||
| 4622 | 4628 | ||
| 4623 | /* Alignment of pointer values. Use offsetof, as it sometimes returns | 4629 | /* Alignment of pointer values. Use alignof, as it sometimes returns |
| 4624 | a smaller alignment than GCC's __alignof__ and mark_memory might | 4630 | a smaller alignment than GCC's __alignof__ and mark_memory might |
| 4625 | miss objects if __alignof__ were used. */ | 4631 | miss objects if __alignof__ were used. */ |
| 4626 | #define GC_POINTER_ALIGNMENT offsetof (struct {char a; void *b;}, b) | 4632 | #define GC_POINTER_ALIGNMENT alignof (void *) |
| 4627 | 4633 | ||
| 4628 | /* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does | 4634 | /* Define POINTERS_MIGHT_HIDE_IN_OBJECTS to 1 if marking via C pointers does |
| 4629 | not suffice, which is the typical case. A host where a Lisp_Object is | 4635 | not suffice, which is the typical case. A host where a Lisp_Object is |
| @@ -5071,17 +5077,11 @@ pure_alloc (size_t size, int type) | |||
| 5071 | #if USE_LSB_TAG | 5077 | #if USE_LSB_TAG |
| 5072 | size_t alignment = (1 << GCTYPEBITS); | 5078 | size_t alignment = (1 << GCTYPEBITS); |
| 5073 | #else | 5079 | #else |
| 5074 | size_t alignment = sizeof (EMACS_INT); | 5080 | size_t alignment = alignof (EMACS_INT); |
| 5075 | 5081 | ||
| 5076 | /* Give Lisp_Floats an extra alignment. */ | 5082 | /* Give Lisp_Floats an extra alignment. */ |
| 5077 | if (type == Lisp_Float) | 5083 | if (type == Lisp_Float) |
| 5078 | { | 5084 | alignment = alignof (struct Lisp_Float); |
| 5079 | #if defined __GNUC__ && __GNUC__ >= 2 | ||
| 5080 | alignment = __alignof (struct Lisp_Float); | ||
| 5081 | #else | ||
| 5082 | alignment = sizeof (struct Lisp_Float); | ||
| 5083 | #endif | ||
| 5084 | } | ||
| 5085 | #endif | 5085 | #endif |
| 5086 | 5086 | ||
| 5087 | again: | 5087 | again: |
| @@ -5416,7 +5416,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5416 | int message_p; | 5416 | int message_p; |
| 5417 | Lisp_Object total[11]; | 5417 | Lisp_Object total[11]; |
| 5418 | ptrdiff_t count = SPECPDL_INDEX (); | 5418 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5419 | EMACS_TIME t1; | 5419 | EMACS_TIME start; |
| 5420 | 5420 | ||
| 5421 | if (abort_on_gc) | 5421 | if (abort_on_gc) |
| 5422 | abort (); | 5422 | abort (); |
| @@ -5426,14 +5426,14 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5426 | if (pure_bytes_used_before_overflow) | 5426 | if (pure_bytes_used_before_overflow) |
| 5427 | return Qnil; | 5427 | return Qnil; |
| 5428 | 5428 | ||
| 5429 | CHECK_CONS_LIST (); | 5429 | check_cons_list (); |
| 5430 | 5430 | ||
| 5431 | /* Don't keep undo information around forever. | 5431 | /* Don't keep undo information around forever. |
| 5432 | Do this early on, so it is no problem if the user quits. */ | 5432 | Do this early on, so it is no problem if the user quits. */ |
| 5433 | FOR_EACH_BUFFER (nextb) | 5433 | FOR_EACH_BUFFER (nextb) |
| 5434 | compact_buffer (nextb); | 5434 | compact_buffer (nextb); |
| 5435 | 5435 | ||
| 5436 | t1 = current_emacs_time (); | 5436 | start = current_emacs_time (); |
| 5437 | 5437 | ||
| 5438 | /* In case user calls debug_print during GC, | 5438 | /* In case user calls debug_print during GC, |
| 5439 | don't let that cause a recursive GC. */ | 5439 | don't let that cause a recursive GC. */ |
| @@ -5594,7 +5594,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5594 | 5594 | ||
| 5595 | UNBLOCK_INPUT; | 5595 | UNBLOCK_INPUT; |
| 5596 | 5596 | ||
| 5597 | CHECK_CONS_LIST (); | 5597 | check_cons_list (); |
| 5598 | 5598 | ||
| 5599 | gc_in_progress = 0; | 5599 | gc_in_progress = 0; |
| 5600 | 5600 | ||
| @@ -5685,18 +5685,16 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5685 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 5685 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
| 5686 | { | 5686 | { |
| 5687 | /* Compute average percentage of zombies. */ | 5687 | /* Compute average percentage of zombies. */ |
| 5688 | double nlive = 0; | 5688 | double nlive = |
| 5689 | 5689 | (total_conses + total_symbols + total_markers + total_strings | |
| 5690 | for (i = 0; i < 7; ++i) | 5690 | + total_vectors + total_floats + total_intervals + total_buffers); |
| 5691 | if (CONSP (total[i])) | ||
| 5692 | nlive += XFASTINT (XCAR (total[i])); | ||
| 5693 | 5691 | ||
| 5694 | avg_live = (avg_live * ngcs + nlive) / (ngcs + 1); | 5692 | avg_live = (avg_live * ngcs + nlive) / (ngcs + 1); |
| 5695 | max_live = max (nlive, max_live); | 5693 | max_live = max (nlive, max_live); |
| 5696 | avg_zombies = (avg_zombies * ngcs + nzombies) / (ngcs + 1); | 5694 | avg_zombies = (avg_zombies * ngcs + nzombies) / (ngcs + 1); |
| 5697 | max_zombies = max (nzombies, max_zombies); | 5695 | max_zombies = max (nzombies, max_zombies); |
| 5698 | ++ngcs; | 5696 | ++ngcs; |
| 5699 | } | 5697 | } |
| 5700 | #endif | 5698 | #endif |
| 5701 | 5699 | ||
| 5702 | if (!NILP (Vpost_gc_hook)) | 5700 | if (!NILP (Vpost_gc_hook)) |
| @@ -5709,10 +5707,9 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5709 | /* Accumulate statistics. */ | 5707 | /* Accumulate statistics. */ |
| 5710 | if (FLOATP (Vgc_elapsed)) | 5708 | if (FLOATP (Vgc_elapsed)) |
| 5711 | { | 5709 | { |
| 5712 | EMACS_TIME t2 = current_emacs_time (); | 5710 | EMACS_TIME since_start = sub_emacs_time (current_emacs_time (), start); |
| 5713 | EMACS_TIME t3 = sub_emacs_time (t2, t1); | ||
| 5714 | Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) | 5711 | Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) |
| 5715 | + EMACS_TIME_TO_DOUBLE (t3)); | 5712 | + EMACS_TIME_TO_DOUBLE (since_start)); |
| 5716 | } | 5713 | } |
| 5717 | 5714 | ||
| 5718 | gcs_done++; | 5715 | gcs_done++; |
| @@ -5929,7 +5926,7 @@ mark_object (Lisp_Object arg) | |||
| 5929 | 5926 | ||
| 5930 | #endif /* not GC_CHECK_MARKED_OBJECTS */ | 5927 | #endif /* not GC_CHECK_MARKED_OBJECTS */ |
| 5931 | 5928 | ||
| 5932 | switch (SWITCH_ENUM_CAST (XTYPE (obj))) | 5929 | switch (XTYPE (obj)) |
| 5933 | { | 5930 | { |
| 5934 | case Lisp_String: | 5931 | case Lisp_String: |
| 5935 | { | 5932 | { |
| @@ -5942,7 +5939,7 @@ mark_object (Lisp_Object arg) | |||
| 5942 | #ifdef GC_CHECK_STRING_BYTES | 5939 | #ifdef GC_CHECK_STRING_BYTES |
| 5943 | /* Check that the string size recorded in the string is the | 5940 | /* Check that the string size recorded in the string is the |
| 5944 | same as the one recorded in the sdata structure. */ | 5941 | same as the one recorded in the sdata structure. */ |
| 5945 | CHECK_STRING_BYTES (ptr); | 5942 | string_bytes (ptr); |
| 5946 | #endif /* GC_CHECK_STRING_BYTES */ | 5943 | #endif /* GC_CHECK_STRING_BYTES */ |
| 5947 | } | 5944 | } |
| 5948 | break; | 5945 | break; |
| @@ -6281,10 +6278,7 @@ gc_sweep (void) | |||
| 6281 | sweep_weak_hash_tables (); | 6278 | sweep_weak_hash_tables (); |
| 6282 | 6279 | ||
| 6283 | sweep_strings (); | 6280 | sweep_strings (); |
| 6284 | #ifdef GC_CHECK_STRING_BYTES | 6281 | check_string_bytes (!noninteractive); |
| 6285 | if (!noninteractive) | ||
| 6286 | check_string_bytes (1); | ||
| 6287 | #endif | ||
| 6288 | 6282 | ||
| 6289 | /* Put all unmarked conses on free list */ | 6283 | /* Put all unmarked conses on free list */ |
| 6290 | { | 6284 | { |
| @@ -6604,11 +6598,7 @@ gc_sweep (void) | |||
| 6604 | } | 6598 | } |
| 6605 | 6599 | ||
| 6606 | sweep_vectors (); | 6600 | sweep_vectors (); |
| 6607 | 6601 | check_string_bytes (!noninteractive); | |
| 6608 | #ifdef GC_CHECK_STRING_BYTES | ||
| 6609 | if (!noninteractive) | ||
| 6610 | check_string_bytes (1); | ||
| 6611 | #endif | ||
| 6612 | } | 6602 | } |
| 6613 | 6603 | ||
| 6614 | 6604 | ||
| @@ -6644,18 +6634,15 @@ Frames, windows, buffers, and subprocesses count as vectors | |||
| 6644 | (but the contents of a buffer's text do not count here). */) | 6634 | (but the contents of a buffer's text do not count here). */) |
| 6645 | (void) | 6635 | (void) |
| 6646 | { | 6636 | { |
| 6647 | Lisp_Object consed[8]; | 6637 | return listn (CONSTYPE_HEAP, 8, |
| 6648 | 6638 | bounded_number (cons_cells_consed), | |
| 6649 | consed[0] = bounded_number (cons_cells_consed); | 6639 | bounded_number (floats_consed), |
| 6650 | consed[1] = bounded_number (floats_consed); | 6640 | bounded_number (vector_cells_consed), |
| 6651 | consed[2] = bounded_number (vector_cells_consed); | 6641 | bounded_number (symbols_consed), |
| 6652 | consed[3] = bounded_number (symbols_consed); | 6642 | bounded_number (string_chars_consed), |
| 6653 | consed[4] = bounded_number (string_chars_consed); | 6643 | bounded_number (misc_objects_consed), |
| 6654 | consed[5] = bounded_number (misc_objects_consed); | 6644 | bounded_number (intervals_consed), |
| 6655 | consed[6] = bounded_number (intervals_consed); | 6645 | bounded_number (strings_consed)); |
| 6656 | consed[7] = bounded_number (strings_consed); | ||
| 6657 | |||
| 6658 | return Flist (8, consed); | ||
| 6659 | } | 6646 | } |
| 6660 | 6647 | ||
| 6661 | /* Find at most FIND_MAX symbols which have OBJ as their value or | 6648 | /* Find at most FIND_MAX symbols which have OBJ as their value or |
| @@ -6836,8 +6823,8 @@ do hash-consing of the objects allocated to pure space. */); | |||
| 6836 | /* We build this in advance because if we wait until we need it, we might | 6823 | /* We build this in advance because if we wait until we need it, we might |
| 6837 | not be able to allocate the memory to hold it. */ | 6824 | not be able to allocate the memory to hold it. */ |
| 6838 | Vmemory_signal_data | 6825 | Vmemory_signal_data |
| 6839 | = pure_cons (Qerror, | 6826 | = listn (CONSTYPE_PURE, 2, Qerror, |
| 6840 | pure_cons (build_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil)); | 6827 | build_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs")); |
| 6841 | 6828 | ||
| 6842 | DEFVAR_LISP ("memory-full", Vmemory_full, | 6829 | DEFVAR_LISP ("memory-full", Vmemory_full, |
| 6843 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); | 6830 | doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); |
| @@ -6876,28 +6863,26 @@ The time is in seconds as a floating point value. */); | |||
| 6876 | #endif | 6863 | #endif |
| 6877 | } | 6864 | } |
| 6878 | 6865 | ||
| 6879 | /* Make some symbols visible to GDB. These cannot be done as enums, like | 6866 | /* When compiled with GCC, GDB might say "No enum type named |
| 6880 | GCTYPEBITS or USE_LSB_TAG, since values might not be in 'int' range. | 6867 | pvec_type" if we don't have at least one symbol with that type, and |
| 6881 | Each symbol X has a corresponding X_VAL symbol, verified to have | 6868 | then xbacktrace could fail. Similarly for the other enums and |
| 6882 | the correct value. | 6869 | their values. */ |
| 6883 | 6870 | union | |
| 6884 | This is last, so that the #undef lines don't mess up later code. */ | 6871 | { |
| 6885 | 6872 | enum CHARTAB_SIZE_BITS CHARTAB_SIZE_BITS; | |
| 6886 | #define ARRAY_MARK_FLAG_VAL PTRDIFF_MIN | 6873 | enum CHAR_TABLE_STANDARD_SLOTS CHAR_TABLE_STANDARD_SLOTS; |
| 6887 | #define PSEUDOVECTOR_FLAG_VAL (PTRDIFF_MAX - PTRDIFF_MAX / 2) | 6874 | enum char_bits char_bits; |
| 6888 | #define VALMASK_VAL (USE_LSB_TAG ? -1 << GCTYPEBITS : VAL_MAX) | 6875 | enum CHECK_LISP_OBJECT_TYPE CHECK_LISP_OBJECT_TYPE; |
| 6889 | 6876 | enum DEFAULT_HASH_SIZE DEFAULT_HASH_SIZE; | |
| 6890 | verify (ARRAY_MARK_FLAG_VAL == ARRAY_MARK_FLAG); | 6877 | enum enum_USE_LSB_TAG enum_USE_LSB_TAG; |
| 6891 | verify (PSEUDOVECTOR_FLAG_VAL == PSEUDOVECTOR_FLAG); | 6878 | enum FLOAT_TO_STRING_BUFSIZE FLOAT_TO_STRING_BUFSIZE; |
| 6892 | verify (VALMASK_VAL == VALMASK); | 6879 | enum Lisp_Bits Lisp_Bits; |
| 6893 | 6880 | enum Lisp_Compiled Lisp_Compiled; | |
| 6894 | #undef ARRAY_MARK_FLAG | 6881 | enum maxargs maxargs; |
| 6895 | #undef PSEUDOVECTOR_FLAG | 6882 | enum MAX_ALLOCA MAX_ALLOCA; |
| 6896 | #undef VALMASK | 6883 | enum More_Lisp_Bits More_Lisp_Bits; |
| 6897 | 6884 | enum pvec_type pvec_type; | |
| 6898 | ptrdiff_t const EXTERNALLY_VISIBLE | 6885 | #if USE_LSB_TAG |
| 6899 | ARRAY_MARK_FLAG = ARRAY_MARK_FLAG_VAL, | 6886 | enum lsb_bits lsb_bits; |
| 6900 | PSEUDOVECTOR_FLAG = PSEUDOVECTOR_FLAG_VAL; | 6887 | #endif |
| 6901 | 6888 | } const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0}; | |
| 6902 | EMACS_INT const EXTERNALLY_VISIBLE | ||
| 6903 | VALMASK = VALMASK_VAL; | ||