aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-19 13:50:01 +0400
committerDmitry Antipov2012-07-19 13:50:01 +0400
commit5b835e1d6e0c6fafc7f27174889358bfde5f2449 (patch)
treefe3d98d833f7bee6f04d69b62dd9bd65c56d1a79 /src/alloc.c
parent9cd47b72e021f76a6e2481d986ce4b0cb0b859d3 (diff)
downloademacs-5b835e1d6e0c6fafc7f27174889358bfde5f2449.tar.gz
emacs-5b835e1d6e0c6fafc7f27174889358bfde5f2449.zip
Tweak the value returned from Fgarbage_collect again.
* src/alloc.c (Fgarbage_collect): New return value, as confirmed in http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00418.html. Adjust documentation. (total_vector_bytes): Rename to total_vector_slots, adjust accounting. (total_free_vector_bytes): Rename to total_free_vector_slots, adjust accounting. (Qstring_bytes, Qvector_slots): New symbols. (syms_of_alloc): DEFSYM them. * lisp/emacs-lisp/chart.el (chart-emacs-storage): Adjust again.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 233137e368e..c52b0475352 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -258,6 +258,7 @@ static char *stack_copy;
258static ptrdiff_t stack_copy_size; 258static ptrdiff_t stack_copy_size;
259#endif 259#endif
260 260
261static Lisp_Object Qstring_bytes, Qvector_slots;
261static Lisp_Object Qgc_cons_threshold; 262static Lisp_Object Qgc_cons_threshold;
262Lisp_Object Qchar_table_extra_slots; 263Lisp_Object Qchar_table_extra_slots;
263 264
@@ -2937,7 +2938,7 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
2937 eassert ((index) < VECTOR_MAX_FREE_LIST_INDEX); \ 2938 eassert ((index) < VECTOR_MAX_FREE_LIST_INDEX); \
2938 (v)->header.next.vector = vector_free_lists[index]; \ 2939 (v)->header.next.vector = vector_free_lists[index]; \
2939 vector_free_lists[index] = (v); \ 2940 vector_free_lists[index] = (v); \
2940 total_free_vector_bytes += (nbytes); \ 2941 total_free_vector_slots += (nbytes) / word_size; \
2941 } while (0) 2942 } while (0)
2942 2943
2943struct vector_block 2944struct vector_block
@@ -2967,9 +2968,9 @@ Lisp_Object zero_vector;
2967 2968
2968static EMACS_INT total_vectors; 2969static EMACS_INT total_vectors;
2969 2970
2970/* Number of bytes used by live and free vectors. */ 2971/* Total size of live and free vectors, in Lisp_Object units. */
2971 2972
2972static EMACS_INT total_vector_bytes, total_free_vector_bytes; 2973static EMACS_INT total_vector_slots, total_free_vector_slots;
2973 2974
2974/* Get a new vector block. */ 2975/* Get a new vector block. */
2975 2976
@@ -3016,7 +3017,7 @@ allocate_vector_from_block (size_t nbytes)
3016 vector = vector_free_lists[index]; 3017 vector = vector_free_lists[index];
3017 vector_free_lists[index] = vector->header.next.vector; 3018 vector_free_lists[index] = vector->header.next.vector;
3018 vector->header.next.nbytes = nbytes; 3019 vector->header.next.nbytes = nbytes;
3019 total_free_vector_bytes -= nbytes; 3020 total_free_vector_slots -= nbytes / word_size;
3020 return vector; 3021 return vector;
3021 } 3022 }
3022 3023
@@ -3031,7 +3032,7 @@ allocate_vector_from_block (size_t nbytes)
3031 vector = vector_free_lists[index]; 3032 vector = vector_free_lists[index];
3032 vector_free_lists[index] = vector->header.next.vector; 3033 vector_free_lists[index] = vector->header.next.vector;
3033 vector->header.next.nbytes = nbytes; 3034 vector->header.next.nbytes = nbytes;
3034 total_free_vector_bytes -= nbytes; 3035 total_free_vector_slots -= nbytes / word_size;
3035 3036
3036 /* Excess bytes are used for the smaller vector, 3037 /* Excess bytes are used for the smaller vector,
3037 which should be set on an appropriate free list. */ 3038 which should be set on an appropriate free list. */
@@ -3085,7 +3086,7 @@ sweep_vectors (void)
3085 struct vector_block *block = vector_blocks, **bprev = &vector_blocks; 3086 struct vector_block *block = vector_blocks, **bprev = &vector_blocks;
3086 struct Lisp_Vector *vector, *next, **vprev = &large_vectors; 3087 struct Lisp_Vector *vector, *next, **vprev = &large_vectors;
3087 3088
3088 total_vectors = total_vector_bytes = total_free_vector_bytes = 0; 3089 total_vectors = total_vector_slots = total_free_vector_slots = 0;
3089 memset (vector_free_lists, 0, sizeof (vector_free_lists)); 3090 memset (vector_free_lists, 0, sizeof (vector_free_lists));
3090 3091
3091 /* Looking through vector blocks. */ 3092 /* Looking through vector blocks. */
@@ -3101,7 +3102,7 @@ sweep_vectors (void)
3101 { 3102 {
3102 VECTOR_UNMARK (vector); 3103 VECTOR_UNMARK (vector);
3103 total_vectors++; 3104 total_vectors++;
3104 total_vector_bytes += vector->header.next.nbytes; 3105 total_vector_slots += vector->header.next.nbytes / word_size;
3105 next = ADVANCE (vector, vector->header.next.nbytes); 3106 next = ADVANCE (vector, vector->header.next.nbytes);
3106 } 3107 }
3107 else 3108 else
@@ -3167,14 +3168,14 @@ sweep_vectors (void)
3167 pseudovector type grows beyond VBLOCK_BYTES_MAX. */ 3168 pseudovector type grows beyond VBLOCK_BYTES_MAX. */
3168 eassert (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_BOOL_VECTOR)); 3169 eassert (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_BOOL_VECTOR));
3169 3170
3170 total_vector_bytes 3171 total_vector_slots
3171 += (bool_header_size 3172 += (bool_header_size
3172 + ((b->size + BOOL_VECTOR_BITS_PER_CHAR - 1) 3173 + ((b->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
3173 / BOOL_VECTOR_BITS_PER_CHAR)); 3174 / BOOL_VECTOR_BITS_PER_CHAR)) / word_size;
3174 } 3175 }
3175 else 3176 else
3176 total_vector_bytes += (header_size 3177 total_vector_slots
3177 + vector->header.size * word_size); 3178 += header_size / word_size + vector->header.size;
3178 vprev = &vector->header.next.vector; 3179 vprev = &vector->header.next.vector;
3179 } 3180 }
3180 else 3181 else
@@ -5381,8 +5382,10 @@ Garbage collection happens automatically if you cons more than
5381 ((CONS INTERNAL-SIZE USED-CONSES FREE-CONSES) 5382 ((CONS INTERNAL-SIZE USED-CONSES FREE-CONSES)
5382 (SYMBOL INTERNAL-SIZE USED-SYMBOLS FREE-SYMBOLS) 5383 (SYMBOL INTERNAL-SIZE USED-SYMBOLS FREE-SYMBOLS)
5383 (MISC INTERNAL-SIZE USED-MISCS FREE-MISCS) 5384 (MISC INTERNAL-SIZE USED-MISCS FREE-MISCS)
5384 (STRING INTERNAL-SIZE USED-STRINGS USED-STRING-BYTES FREE-STRING) 5385 (STRING INTERNAL-SIZE USED-STRINGS FREE-STRING)
5385 (VECTOR INTERNAL-SIZE USED-VECTORS USED-VECTOR-BYTES FREE-VECTOR-BYTES) 5386 (STRING-BYTES 1 USED-STRING-BYTES)
5387 (VECTOR INTERNAL-SIZE USED-VECTORS)
5388 (VECTOR-SLOTS INTERNAL-SIZE USED-VECTOR-SLOTS FREE-VECTOR-SLOTS)
5386 (FLOAT INTERNAL-SIZE USED-FLOATS FREE-FLOATS) 5389 (FLOAT INTERNAL-SIZE USED-FLOATS FREE-FLOATS)
5387 (INTERVAL INTERNAL-SIZE USED-INTERVALS FREE-INTERVALS) 5390 (INTERVAL INTERNAL-SIZE USED-INTERVALS FREE-INTERVALS)
5388 (BUFFER INTERNAL-SIZE USED-BUFFERS)) 5391 (BUFFER INTERNAL-SIZE USED-BUFFERS))
@@ -5396,7 +5399,7 @@ See Info node `(elisp)Garbage Collection'. */)
5396 char stack_top_variable; 5399 char stack_top_variable;
5397 ptrdiff_t i; 5400 ptrdiff_t i;
5398 int message_p; 5401 int message_p;
5399 Lisp_Object total[8]; 5402 Lisp_Object total[10];
5400 ptrdiff_t count = SPECPDL_INDEX (); 5403 ptrdiff_t count = SPECPDL_INDEX ();
5401 EMACS_TIME t1; 5404 EMACS_TIME t1;
5402 5405
@@ -5596,7 +5599,7 @@ See Info node `(elisp)Garbage Collection'. */)
5596 tot += total_symbols * sizeof (struct Lisp_Symbol); 5599 tot += total_symbols * sizeof (struct Lisp_Symbol);
5597 tot += total_markers * sizeof (union Lisp_Misc); 5600 tot += total_markers * sizeof (union Lisp_Misc);
5598 tot += total_string_bytes; 5601 tot += total_string_bytes;
5599 tot += total_vector_bytes; 5602 tot += total_vector_slots * word_size;
5600 tot += total_floats * sizeof (struct Lisp_Float); 5603 tot += total_floats * sizeof (struct Lisp_Float);
5601 tot += total_intervals * sizeof (struct interval); 5604 tot += total_intervals * sizeof (struct interval);
5602 tot += total_strings * sizeof (struct Lisp_String); 5605 tot += total_strings * sizeof (struct Lisp_String);
@@ -5633,25 +5636,29 @@ See Info node `(elisp)Garbage Collection'. */)
5633 bounded_number (total_markers), 5636 bounded_number (total_markers),
5634 bounded_number (total_free_markers)); 5637 bounded_number (total_free_markers));
5635 5638
5636 total[3] = list5 (Qstring, make_number (sizeof (struct Lisp_String)), 5639 total[3] = list4 (Qstring, make_number (sizeof (struct Lisp_String)),
5637 bounded_number (total_strings), 5640 bounded_number (total_strings),
5638 bounded_number (total_string_bytes),
5639 bounded_number (total_free_strings)); 5641 bounded_number (total_free_strings));
5640 5642
5641 total[4] = list5 (Qvector, make_number (sizeof (struct Lisp_Vector)), 5643 total[4] = list3 (Qstring_bytes, make_number (1),
5642 bounded_number (total_vectors), 5644 bounded_number (total_string_bytes));
5643 bounded_number (total_vector_bytes),
5644 bounded_number (total_free_vector_bytes));
5645 5645
5646 total[5] = list4 (Qfloat, make_number (sizeof (struct Lisp_Float)), 5646 total[5] = list3 (Qvector, make_number (sizeof (struct Lisp_Vector)),
5647 bounded_number (total_vectors));
5648
5649 total[6] = list4 (Qvector_slots, make_number (word_size),
5650 bounded_number (total_vector_slots),
5651 bounded_number (total_free_vector_slots));
5652
5653 total[7] = list4 (Qfloat, make_number (sizeof (struct Lisp_Float)),
5647 bounded_number (total_floats), 5654 bounded_number (total_floats),
5648 bounded_number (total_free_floats)); 5655 bounded_number (total_free_floats));
5649 5656
5650 total[6] = list4 (Qinterval, make_number (sizeof (struct interval)), 5657 total[8] = list4 (Qinterval, make_number (sizeof (struct interval)),
5651 bounded_number (total_intervals), 5658 bounded_number (total_intervals),
5652 bounded_number (total_free_intervals)); 5659 bounded_number (total_free_intervals));
5653 5660
5654 total[7] = list3 (Qbuffer, make_number (sizeof (struct buffer)), 5661 total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)),
5655 bounded_number (total_buffers)); 5662 bounded_number (total_buffers));
5656 5663
5657#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 5664#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
@@ -6620,7 +6627,7 @@ if heap statistics are not available. Both counters are in units of
6620 + total_free_floats * sizeof (struct Lisp_Float) 6627 + total_free_floats * sizeof (struct Lisp_Float)
6621 + total_free_intervals * sizeof (struct interval) 6628 + total_free_intervals * sizeof (struct interval)
6622 + total_free_strings * sizeof (struct Lisp_String) 6629 + total_free_strings * sizeof (struct Lisp_String)
6623 + total_free_vector_bytes 6630 + total_free_vector_slots * word_size
6624 + 1023) >> 10)); 6631 + 1023) >> 10));
6625#ifdef DOUG_LEA_MALLOC 6632#ifdef DOUG_LEA_MALLOC
6626 XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10)); 6633 XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10));
@@ -6842,6 +6849,9 @@ do hash-consing of the objects allocated to pure space. */);
6842 doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); 6849 doc: /* Non-nil means Emacs cannot get much more Lisp memory. */);
6843 Vmemory_full = Qnil; 6850 Vmemory_full = Qnil;
6844 6851
6852 DEFSYM (Qstring_bytes, "string-bytes");
6853 DEFSYM (Qvector_slots, "vector-slots");
6854
6845 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); 6855 DEFSYM (Qgc_cons_threshold, "gc-cons-threshold");
6846 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); 6856 DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots");
6847 6857