From: Dmitry Antipov Date: Thu, 19 Jul 2012 09:50:01 +0000 (+0400) Subject: Tweak the value returned from Fgarbage_collect again. X-Git-Tag: emacs-24.2.90~1130 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5b835e1d6e0c6fafc7f27174889358bfde5f2449;p=emacs.git 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 25f99d2b824..12186c7bef7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-07-19 Dmitry Antipov + + Next round of tweaks caused by Fgarbage_collect changes. + * emacs-lisp/chart.el (chart-emacs-storage): Adjust again. + 2012-07-19 Dmitry Antipov Compact buffers when idle. diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el index 5699d827d4f..1451e1a2af4 100644 --- a/lisp/emacs-lisp/chart.el +++ b/lisp/emacs-lisp/chart.el @@ -680,18 +680,20 @@ SORT-PRED if desired." (symbol-info (nth 1 data)) (misc-info (nth 2 data)) (string-info (nth 3 data)) - (vector-info (nth 4 data)) - (float-info (nth 5 data)) - (interval-info (nth 6 data)) - (buffer-info (nth 7 data)) + (string-bytes-info (nth 4 data)) + ;; (nth 5 data) is not used + (vector-slots-info (nth 6 data)) + (float-info (nth 7 data)) + (interval-info (nth 8 data)) + (buffer-info (nth 9 data)) (names '("conses" "symbols" "miscs" "strings" "vectors" "floats" "intervals" "buffers")) (nums (list (* (nth 1 cons-info) (nth 2 cons-info)) (* (nth 1 symbol-info) (nth 2 symbol-info)) (* (nth 1 misc-info) (nth 2 misc-info)) (+ (* (nth 1 string-info) (nth 2 string-info)) - (nth 3 string-info)) - (nth 3 vector-info) + (nth 2 string-bytes-info)) + (* (nth 1 vector-slots-info) (nth 2 vector-slots-info)) (* (nth 1 float-info) (nth 2 float-info)) (* (nth 1 interval-info) (nth 2 interval-info)) (* (nth 1 buffer-info) (nth 2 buffer-info))))) diff --git a/src/ChangeLog b/src/ChangeLog index 7a0942f9c7e..517d61c4e40 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2012-07-19 Dmitry Antipov + + Tweak the value returned from Fgarbage_collect again. + * 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. + 2012-07-19 Dmitry Antipov Buffer compaction primitive which may be used from Lisp. 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; static ptrdiff_t stack_copy_size; #endif +static Lisp_Object Qstring_bytes, Qvector_slots; static Lisp_Object Qgc_cons_threshold; Lisp_Object Qchar_table_extra_slots; @@ -2937,7 +2938,7 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS)); eassert ((index) < VECTOR_MAX_FREE_LIST_INDEX); \ (v)->header.next.vector = vector_free_lists[index]; \ vector_free_lists[index] = (v); \ - total_free_vector_bytes += (nbytes); \ + total_free_vector_slots += (nbytes) / word_size; \ } while (0) struct vector_block @@ -2967,9 +2968,9 @@ Lisp_Object zero_vector; static EMACS_INT total_vectors; -/* Number of bytes used by live and free vectors. */ +/* Total size of live and free vectors, in Lisp_Object units. */ -static EMACS_INT total_vector_bytes, total_free_vector_bytes; +static EMACS_INT total_vector_slots, total_free_vector_slots; /* Get a new vector block. */ @@ -3016,7 +3017,7 @@ allocate_vector_from_block (size_t nbytes) vector = vector_free_lists[index]; vector_free_lists[index] = vector->header.next.vector; vector->header.next.nbytes = nbytes; - total_free_vector_bytes -= nbytes; + total_free_vector_slots -= nbytes / word_size; return vector; } @@ -3031,7 +3032,7 @@ allocate_vector_from_block (size_t nbytes) vector = vector_free_lists[index]; vector_free_lists[index] = vector->header.next.vector; vector->header.next.nbytes = nbytes; - total_free_vector_bytes -= nbytes; + total_free_vector_slots -= nbytes / word_size; /* Excess bytes are used for the smaller vector, which should be set on an appropriate free list. */ @@ -3085,7 +3086,7 @@ sweep_vectors (void) struct vector_block *block = vector_blocks, **bprev = &vector_blocks; struct Lisp_Vector *vector, *next, **vprev = &large_vectors; - total_vectors = total_vector_bytes = total_free_vector_bytes = 0; + total_vectors = total_vector_slots = total_free_vector_slots = 0; memset (vector_free_lists, 0, sizeof (vector_free_lists)); /* Looking through vector blocks. */ @@ -3101,7 +3102,7 @@ sweep_vectors (void) { VECTOR_UNMARK (vector); total_vectors++; - total_vector_bytes += vector->header.next.nbytes; + total_vector_slots += vector->header.next.nbytes / word_size; next = ADVANCE (vector, vector->header.next.nbytes); } else @@ -3167,14 +3168,14 @@ sweep_vectors (void) pseudovector type grows beyond VBLOCK_BYTES_MAX. */ eassert (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_BOOL_VECTOR)); - total_vector_bytes + total_vector_slots += (bool_header_size + ((b->size + BOOL_VECTOR_BITS_PER_CHAR - 1) - / BOOL_VECTOR_BITS_PER_CHAR)); + / BOOL_VECTOR_BITS_PER_CHAR)) / word_size; } else - total_vector_bytes += (header_size - + vector->header.size * word_size); + total_vector_slots + += header_size / word_size + vector->header.size; vprev = &vector->header.next.vector; } else @@ -5381,8 +5382,10 @@ Garbage collection happens automatically if you cons more than ((CONS INTERNAL-SIZE USED-CONSES FREE-CONSES) (SYMBOL INTERNAL-SIZE USED-SYMBOLS FREE-SYMBOLS) (MISC INTERNAL-SIZE USED-MISCS FREE-MISCS) - (STRING INTERNAL-SIZE USED-STRINGS USED-STRING-BYTES FREE-STRING) - (VECTOR INTERNAL-SIZE USED-VECTORS USED-VECTOR-BYTES FREE-VECTOR-BYTES) + (STRING INTERNAL-SIZE USED-STRINGS FREE-STRING) + (STRING-BYTES 1 USED-STRING-BYTES) + (VECTOR INTERNAL-SIZE USED-VECTORS) + (VECTOR-SLOTS INTERNAL-SIZE USED-VECTOR-SLOTS FREE-VECTOR-SLOTS) (FLOAT INTERNAL-SIZE USED-FLOATS FREE-FLOATS) (INTERVAL INTERNAL-SIZE USED-INTERVALS FREE-INTERVALS) (BUFFER INTERNAL-SIZE USED-BUFFERS)) @@ -5396,7 +5399,7 @@ See Info node `(elisp)Garbage Collection'. */) char stack_top_variable; ptrdiff_t i; int message_p; - Lisp_Object total[8]; + Lisp_Object total[10]; ptrdiff_t count = SPECPDL_INDEX (); EMACS_TIME t1; @@ -5596,7 +5599,7 @@ See Info node `(elisp)Garbage Collection'. */) tot += total_symbols * sizeof (struct Lisp_Symbol); tot += total_markers * sizeof (union Lisp_Misc); tot += total_string_bytes; - tot += total_vector_bytes; + tot += total_vector_slots * word_size; tot += total_floats * sizeof (struct Lisp_Float); tot += total_intervals * sizeof (struct interval); tot += total_strings * sizeof (struct Lisp_String); @@ -5633,25 +5636,29 @@ See Info node `(elisp)Garbage Collection'. */) bounded_number (total_markers), bounded_number (total_free_markers)); - total[3] = list5 (Qstring, make_number (sizeof (struct Lisp_String)), + total[3] = list4 (Qstring, make_number (sizeof (struct Lisp_String)), bounded_number (total_strings), - bounded_number (total_string_bytes), bounded_number (total_free_strings)); - total[4] = list5 (Qvector, make_number (sizeof (struct Lisp_Vector)), - bounded_number (total_vectors), - bounded_number (total_vector_bytes), - bounded_number (total_free_vector_bytes)); + total[4] = list3 (Qstring_bytes, make_number (1), + bounded_number (total_string_bytes)); - total[5] = list4 (Qfloat, make_number (sizeof (struct Lisp_Float)), + total[5] = list3 (Qvector, make_number (sizeof (struct Lisp_Vector)), + bounded_number (total_vectors)); + + total[6] = list4 (Qvector_slots, make_number (word_size), + bounded_number (total_vector_slots), + bounded_number (total_free_vector_slots)); + + total[7] = list4 (Qfloat, make_number (sizeof (struct Lisp_Float)), bounded_number (total_floats), bounded_number (total_free_floats)); - total[6] = list4 (Qinterval, make_number (sizeof (struct interval)), + total[8] = list4 (Qinterval, make_number (sizeof (struct interval)), bounded_number (total_intervals), bounded_number (total_free_intervals)); - total[7] = list3 (Qbuffer, make_number (sizeof (struct buffer)), + total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)), bounded_number (total_buffers)); #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 + total_free_floats * sizeof (struct Lisp_Float) + total_free_intervals * sizeof (struct interval) + total_free_strings * sizeof (struct Lisp_String) - + total_free_vector_bytes + + total_free_vector_slots * word_size + 1023) >> 10)); #ifdef DOUG_LEA_MALLOC XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10)); @@ -6842,6 +6849,9 @@ do hash-consing of the objects allocated to pure space. */); doc: /* Non-nil means Emacs cannot get much more Lisp memory. */); Vmemory_full = Qnil; + DEFSYM (Qstring_bytes, "string-bytes"); + DEFSYM (Qvector_slots, "vector-slots"); + DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots");