diff options
| author | Dmitry Antipov | 2012-07-20 18:07:28 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-20 18:07:28 +0400 |
| commit | f8643a6b9e35af22b69a84f83df5d9410de82f16 (patch) | |
| tree | 922310c5216f43845258318070a72c2f616c063c /src | |
| parent | dac616ff9f51b77e399a06863a79446958c4f840 (diff) | |
| download | emacs-f8643a6b9e35af22b69a84f83df5d9410de82f16.tar.gz emacs-f8643a6b9e35af22b69a84f83df5d9410de82f16.zip | |
Extend the value returned by Fgarbage_collect with heap statistics.
* alloc.c (Qheap): New symbol.
(syms_of_alloc): DEFSYM it.
(Fgarbage_collect): If DOUG_LEA_MALLOC, add mallinfo data.
(Fmemory_free): Remove.
(syms_of_alloc): Don't defsubr it.
* buffer.c (Fcompact_buffer): Remove.
(syms_of_buffer): Don't defsubr it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/alloc.c | 42 | ||||
| -rw-r--r-- | src/buffer.c | 14 |
3 files changed, 23 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 81122d45279..d7d02a2262a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Extend the value returned by Fgarbage_collect with heap statistics. | ||
| 4 | * alloc.c (Qheap): New symbol. | ||
| 5 | (syms_of_alloc): DEFSYM it. | ||
| 6 | (Fgarbage_collect): If DOUG_LEA_MALLOC, add mallinfo data. | ||
| 7 | (Fmemory_free): Remove. | ||
| 8 | (syms_of_alloc): Don't defsubr it. | ||
| 9 | * buffer.c (Fcompact_buffer): Remove. | ||
| 10 | (syms_of_buffer): Don't defsubr it. | ||
| 11 | |||
| 12 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 13 | |||
| 3 | Make maybe_gc inline. | 14 | Make maybe_gc inline. |
| 4 | Verify that inlining is always possible (GCC 4.7.1, -O3 -Winline). | 15 | Verify that inlining is always possible (GCC 4.7.1, -O3 -Winline). |
| 5 | * lisp.h (consing_since_gc, gc_relative_threshold) | 16 | * lisp.h (consing_since_gc, gc_relative_threshold) |
diff --git a/src/alloc.c b/src/alloc.c index e7d67e95dbe..05e676836c5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -258,7 +258,7 @@ static char *stack_copy; | |||
| 258 | static ptrdiff_t stack_copy_size; | 258 | static ptrdiff_t stack_copy_size; |
| 259 | #endif | 259 | #endif |
| 260 | 260 | ||
| 261 | static Lisp_Object Qstring_bytes, Qvector_slots; | 261 | static Lisp_Object Qstring_bytes, Qvector_slots, Qheap; |
| 262 | static Lisp_Object Qgc_cons_threshold; | 262 | static Lisp_Object Qgc_cons_threshold; |
| 263 | Lisp_Object Qchar_table_extra_slots; | 263 | Lisp_Object Qchar_table_extra_slots; |
| 264 | 264 | ||
| @@ -5396,7 +5396,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5396 | char stack_top_variable; | 5396 | char stack_top_variable; |
| 5397 | ptrdiff_t i; | 5397 | ptrdiff_t i; |
| 5398 | int message_p; | 5398 | int message_p; |
| 5399 | Lisp_Object total[10]; | 5399 | Lisp_Object total[11]; |
| 5400 | ptrdiff_t count = SPECPDL_INDEX (); | 5400 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5401 | EMACS_TIME t1; | 5401 | EMACS_TIME t1; |
| 5402 | 5402 | ||
| @@ -5655,6 +5655,15 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5655 | total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)), | 5655 | total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)), |
| 5656 | bounded_number (total_buffers)); | 5656 | bounded_number (total_buffers)); |
| 5657 | 5657 | ||
| 5658 | total[10] = list4 (Qheap, make_number (1024), | ||
| 5659 | #ifdef DOUG_LEA_MALLOC | ||
| 5660 | bounded_number ((mallinfo ().uordblks + 1023) >> 10), | ||
| 5661 | bounded_number ((mallinfo ().fordblks + 1023) >> 10) | ||
| 5662 | #else | ||
| 5663 | Qnil, Qnil | ||
| 5664 | #endif | ||
| 5665 | ); | ||
| 5666 | |||
| 5658 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 5667 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
| 5659 | { | 5668 | { |
| 5660 | /* Compute average percentage of zombies. */ | 5669 | /* Compute average percentage of zombies. */ |
| @@ -6602,33 +6611,6 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */) | |||
| 6602 | return end; | 6611 | return end; |
| 6603 | } | 6612 | } |
| 6604 | 6613 | ||
| 6605 | DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0, | ||
| 6606 | doc: /* Return a list (E H) of two measures of free memory. | ||
| 6607 | E counts free lists maintained by Emacs itself. H counts the heap, | ||
| 6608 | freed by Emacs but not released to the operating system; this is zero | ||
| 6609 | if heap statistics are not available. Both counters are in units of | ||
| 6610 | 1024 bytes, rounded up. */) | ||
| 6611 | (void) | ||
| 6612 | { | ||
| 6613 | /* Make the return value first, so that its storage is accounted for. */ | ||
| 6614 | Lisp_Object val = Fmake_list (make_number (2), make_number (0)); | ||
| 6615 | |||
| 6616 | XSETCAR (val, | ||
| 6617 | bounded_number | ||
| 6618 | ((total_free_conses * sizeof (struct Lisp_Cons) | ||
| 6619 | + total_free_markers * sizeof (union Lisp_Misc) | ||
| 6620 | + total_free_symbols * sizeof (struct Lisp_Symbol) | ||
| 6621 | + total_free_floats * sizeof (struct Lisp_Float) | ||
| 6622 | + total_free_intervals * sizeof (struct interval) | ||
| 6623 | + total_free_strings * sizeof (struct Lisp_String) | ||
| 6624 | + total_free_vector_slots * word_size | ||
| 6625 | + 1023) >> 10)); | ||
| 6626 | #ifdef DOUG_LEA_MALLOC | ||
| 6627 | XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10)); | ||
| 6628 | #endif | ||
| 6629 | return val; | ||
| 6630 | } | ||
| 6631 | |||
| 6632 | DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, | 6614 | DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0, |
| 6633 | doc: /* Return a list of counters that measure how much consing there has been. | 6615 | doc: /* Return a list of counters that measure how much consing there has been. |
| 6634 | Each of these counters increments for a certain kind of object. | 6616 | Each of these counters increments for a certain kind of object. |
| @@ -6845,6 +6827,7 @@ do hash-consing of the objects allocated to pure space. */); | |||
| 6845 | 6827 | ||
| 6846 | DEFSYM (Qstring_bytes, "string-bytes"); | 6828 | DEFSYM (Qstring_bytes, "string-bytes"); |
| 6847 | DEFSYM (Qvector_slots, "vector-slots"); | 6829 | DEFSYM (Qvector_slots, "vector-slots"); |
| 6830 | DEFSYM (Qheap, "heap"); | ||
| 6848 | 6831 | ||
| 6849 | DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); | 6832 | DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); |
| 6850 | DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); | 6833 | DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); |
| @@ -6868,7 +6851,6 @@ The time is in seconds as a floating point value. */); | |||
| 6868 | defsubr (&Spurecopy); | 6851 | defsubr (&Spurecopy); |
| 6869 | defsubr (&Sgarbage_collect); | 6852 | defsubr (&Sgarbage_collect); |
| 6870 | defsubr (&Smemory_limit); | 6853 | defsubr (&Smemory_limit); |
| 6871 | defsubr (&Smemory_free); | ||
| 6872 | defsubr (&Smemory_use_counts); | 6854 | defsubr (&Smemory_use_counts); |
| 6873 | 6855 | ||
| 6874 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 6856 | #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
diff --git a/src/buffer.c b/src/buffer.c index 04d83d76945..b722ff135dd 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1474,19 +1474,6 @@ compact_buffer (struct buffer *buffer) | |||
| 1474 | return 0; | 1474 | return 0; |
| 1475 | } | 1475 | } |
| 1476 | 1476 | ||
| 1477 | DEFUN ("compact-buffer", Fcompact_buffer, Scompact_buffer, 0, 1, 0, | ||
| 1478 | doc: /* Compact BUFFER by truncating undo list and shrinking the gap. | ||
| 1479 | If buffer is nil, compact current buffer. Compaction is performed | ||
| 1480 | only if buffer was changed since last compaction. Return t if | ||
| 1481 | buffer compaction was performed, and nil otherwise. */) | ||
| 1482 | (Lisp_Object buffer) | ||
| 1483 | { | ||
| 1484 | if (NILP (buffer)) | ||
| 1485 | XSETBUFFER (buffer, current_buffer); | ||
| 1486 | CHECK_BUFFER (buffer); | ||
| 1487 | return compact_buffer (XBUFFER (buffer)) ? Qt : Qnil; | ||
| 1488 | } | ||
| 1489 | |||
| 1490 | DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", | 1477 | DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", |
| 1491 | doc: /* Kill the buffer specified by BUFFER-OR-NAME. | 1478 | doc: /* Kill the buffer specified by BUFFER-OR-NAME. |
| 1492 | The argument may be a buffer or the name of an existing buffer. | 1479 | The argument may be a buffer or the name of an existing buffer. |
| @@ -6048,7 +6035,6 @@ and `bury-buffer-internal'. */); | |||
| 6048 | defsubr (&Srename_buffer); | 6035 | defsubr (&Srename_buffer); |
| 6049 | defsubr (&Sother_buffer); | 6036 | defsubr (&Sother_buffer); |
| 6050 | defsubr (&Sbuffer_enable_undo); | 6037 | defsubr (&Sbuffer_enable_undo); |
| 6051 | defsubr (&Scompact_buffer); | ||
| 6052 | defsubr (&Skill_buffer); | 6038 | defsubr (&Skill_buffer); |
| 6053 | defsubr (&Sbury_buffer_internal); | 6039 | defsubr (&Sbury_buffer_internal); |
| 6054 | defsubr (&Sset_buffer_major_mode); | 6040 | defsubr (&Sset_buffer_major_mode); |