Extend the value returned by Fgarbage_collect with heap statistics.
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 20 Jul 2012 14:07:28 +0000 (18:07 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 20 Jul 2012 14:07:28 +0000 (18:07 +0400)
* 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.

src/ChangeLog
src/alloc.c
src/buffer.c

index 81122d4..d7d02a2 100644 (file)
@@ -1,3 +1,14 @@
+2012-07-20  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       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.
+
 2012-07-20  Dmitry Antipov  <dmantipov@yandex.ru>
 
        Make maybe_gc inline.
index e7d67e9..05e6768 100644 (file)
@@ -258,7 +258,7 @@ static char *stack_copy;
 static ptrdiff_t stack_copy_size;
 #endif
 
-static Lisp_Object Qstring_bytes, Qvector_slots;
+static Lisp_Object Qstring_bytes, Qvector_slots, Qheap;
 static Lisp_Object Qgc_cons_threshold;
 Lisp_Object Qchar_table_extra_slots;
 
@@ -5396,7 +5396,7 @@ See Info node `(elisp)Garbage Collection'.  */)
   char stack_top_variable;
   ptrdiff_t i;
   int message_p;
-  Lisp_Object total[10];
+  Lisp_Object total[11];
   ptrdiff_t count = SPECPDL_INDEX ();
   EMACS_TIME t1;
 
@@ -5655,6 +5655,15 @@ See Info node `(elisp)Garbage Collection'.  */)
   total[9] = list3 (Qbuffer, make_number (sizeof (struct buffer)),
                    bounded_number (total_buffers));
 
+  total[10] = list4 (Qheap, make_number (1024),
+#ifdef DOUG_LEA_MALLOC
+                    bounded_number ((mallinfo ().uordblks + 1023) >> 10),
+                    bounded_number ((mallinfo ().fordblks + 1023) >> 10)
+#else
+                    Qnil, Qnil
+#endif
+                    );
+
 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
   {
     /* Compute average percentage of zombies.  */
@@ -6602,33 +6611,6 @@ We divide the value by 1024 to make sure it fits in a Lisp integer.  */)
   return end;
 }
 
-DEFUN ("memory-free", Fmemory_free, Smemory_free, 0, 0, 0,
-       doc: /* Return a list (E H) of two measures of free memory.
-E counts free lists maintained by Emacs itself.  H counts the heap,
-freed by Emacs but not released to the operating system; this is zero
-if heap statistics are not available.  Both counters are in units of
-1024 bytes, rounded up.  */)
-     (void)
-{
-  /* Make the return value first, so that its storage is accounted for.  */
-  Lisp_Object val = Fmake_list (make_number (2), make_number (0));
-
-  XSETCAR (val,
-          bounded_number
-          ((total_free_conses * sizeof (struct Lisp_Cons)
-            + total_free_markers * sizeof (union Lisp_Misc)
-            + total_free_symbols * sizeof (struct Lisp_Symbol)
-            + total_free_floats * sizeof (struct Lisp_Float)
-            + total_free_intervals * sizeof (struct interval)
-            + total_free_strings * sizeof (struct Lisp_String)
-            + total_free_vector_slots * word_size
-            + 1023) >> 10));
-#ifdef DOUG_LEA_MALLOC
-  XSETCAR (XCDR (val), bounded_number ((mallinfo ().fordblks + 1023) >> 10));
-#endif
-  return val;
-}
-
 DEFUN ("memory-use-counts", Fmemory_use_counts, Smemory_use_counts, 0, 0, 0,
        doc: /* Return a list of counters that measure how much consing there has been.
 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.  */);
 
   DEFSYM (Qstring_bytes, "string-bytes");
   DEFSYM (Qvector_slots, "vector-slots");
+  DEFSYM (Qheap, "heap");
 
   DEFSYM (Qgc_cons_threshold, "gc-cons-threshold");
   DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots");
@@ -6868,7 +6851,6 @@ The time is in seconds as a floating point value.  */);
   defsubr (&Spurecopy);
   defsubr (&Sgarbage_collect);
   defsubr (&Smemory_limit);
-  defsubr (&Smemory_free);
   defsubr (&Smemory_use_counts);
 
 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
index 04d83d7..b722ff1 100644 (file)
@@ -1474,19 +1474,6 @@ compact_buffer (struct buffer *buffer)
   return 0;
 }
 
-DEFUN ("compact-buffer", Fcompact_buffer, Scompact_buffer, 0, 1, 0,
-       doc: /* Compact BUFFER by truncating undo list and shrinking the gap.
-If buffer is nil, compact current buffer.  Compaction is performed
-only if buffer was changed since last compaction.  Return t if
-buffer compaction was performed, and nil otherwise.  */)
-  (Lisp_Object buffer)
-{
-  if (NILP (buffer))
-    XSETBUFFER (buffer, current_buffer);
-  CHECK_BUFFER (buffer);
-  return compact_buffer (XBUFFER (buffer)) ? Qt : Qnil;
-}
-
 DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
        doc: /* Kill the buffer specified by BUFFER-OR-NAME.
 The argument may be a buffer or the name of an existing buffer.
@@ -6048,7 +6035,6 @@ and `bury-buffer-internal'.  */);
   defsubr (&Srename_buffer);
   defsubr (&Sother_buffer);
   defsubr (&Sbuffer_enable_undo);
-  defsubr (&Scompact_buffer);
   defsubr (&Skill_buffer);
   defsubr (&Sbury_buffer_internal);
   defsubr (&Sset_buffer_major_mode);