emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109163: Cleanup calls to Fgarbage_co


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109163: Cleanup calls to Fgarbage_collect.
Date: Fri, 20 Jul 2012 09:28:00 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109163
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Fri 2012-07-20 09:28:00 +0400
message:
  Cleanup calls to Fgarbage_collect.
  * lisp.h (maybe_gc): New prototype.
  (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold):
  Remove declarations.
  * alloc.c (maybe_gc): New function.
  (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold):
  Make them static.
  * bytecode.c (MAYBE_GC): Use maybe_gc.
  * eval.c (eval_sub, Ffuncall): Likewise.
  * keyboard.c (read_char): Likewise.  Adjust call to maybe_gc
  to avoid dependency from auto-save feature.
modified:
  src/ChangeLog
  src/alloc.c
  src/bytecode.c
  src/eval.c
  src/keyboard.c
  src/lisp.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-19 22:35:58 +0000
+++ b/src/ChangeLog     2012-07-20 05:28:00 +0000
@@ -1,3 +1,17 @@
+2012-07-20  Dmitry Antipov  <address@hidden>
+
+       Cleanup calls to Fgarbage_collect.
+       * lisp.h (maybe_gc): New prototype.
+       (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold):
+       Remove declarations.
+       * alloc.c (maybe_gc): New function.
+       (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold):
+       Make them static.
+       * bytecode.c (MAYBE_GC): Use maybe_gc.
+       * eval.c (eval_sub, Ffuncall): Likewise.
+       * keyboard.c (read_char): Likewise.  Adjust call to maybe_gc
+       to avoid dependency from auto-save feature.
+
 2012-07-19  Paul Eggert  <address@hidden>
 
        * buffer.h (FOR_EACH_BUFFER): Rename from 'for_each_buffer'.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-07-19 22:35:58 +0000
+++ b/src/alloc.c       2012-07-20 05:28:00 +0000
@@ -166,16 +166,16 @@
 
 /* Number of bytes of consing done since the last gc.  */
 
-EMACS_INT consing_since_gc;
+static EMACS_INT consing_since_gc;
 
 /* Similar minimum, computed from Vgc_cons_percentage.  */
 
-EMACS_INT gc_relative_threshold;
+static EMACS_INT gc_relative_threshold;
 
 /* Minimum number of bytes of consing since GC before next GC,
    when memory is full.  */
 
-EMACS_INT memory_full_cons_threshold;
+static EMACS_INT memory_full_cons_threshold;
 
 /* Nonzero during GC.  */
 
@@ -5374,6 +5374,18 @@
   return make_number (min (MOST_POSITIVE_FIXNUM, number));
 }
 
+/* Check whether it's time for GC, and run it if so.  */
+
+void
+maybe_gc (void)
+{
+  if ((consing_since_gc > gc_cons_threshold
+       && consing_since_gc > gc_relative_threshold)
+      || (!NILP (Vmemory_full)
+         && consing_since_gc > memory_full_cons_threshold))
+    Fgarbage_collect ();
+}
+
 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
        doc: /* Reclaim storage for Lisp objects no longer needed.
 Garbage collection happens automatically if you cons more than

=== modified file 'src/bytecode.c'
--- a/src/bytecode.c    2012-07-10 22:40:34 +0000
+++ b/src/bytecode.c    2012-07-20 05:28:00 +0000
@@ -423,15 +423,11 @@
 /* Garbage collect if we have consed enough since the last time.
    We do this at every branch, to avoid loops that never GC.  */
 
-#define MAYBE_GC()                                     \
- do {                                                  \
-  if (consing_since_gc > gc_cons_threshold             \
-      && consing_since_gc > gc_relative_threshold)     \
-    {                                                  \
-      BEFORE_POTENTIAL_GC ();                          \
-      Fgarbage_collect ();                             \
-      AFTER_POTENTIAL_GC ();                           \
-    }                                                  \
+#define MAYBE_GC()             \
+  do {                         \
+   BEFORE_POTENTIAL_GC ();     \
+   maybe_gc ();                        \
+   AFTER_POTENTIAL_GC ();      \
  } while (0)
 
 /* Check for jumping out of range.  */

=== modified file 'src/eval.c'
--- a/src/eval.c        2012-07-18 15:20:33 +0000
+++ b/src/eval.c        2012-07-20 05:28:00 +0000
@@ -2040,15 +2040,7 @@
     return form;
 
   QUIT;
-  if ((consing_since_gc > gc_cons_threshold
-       && consing_since_gc > gc_relative_threshold)
-      ||
-      (!NILP (Vmemory_full) && consing_since_gc > memory_full_cons_threshold))
-    {
-      GCPRO1 (form);
-      Fgarbage_collect ();
-      UNGCPRO;
-    }
+  maybe_gc ();
 
   if (++lisp_eval_depth > max_lisp_eval_depth)
     {
@@ -2737,11 +2729,7 @@
   ptrdiff_t i;
 
   QUIT;
-  if ((consing_since_gc > gc_cons_threshold
-       && consing_since_gc > gc_relative_threshold)
-      ||
-      (!NILP (Vmemory_full) && consing_since_gc > memory_full_cons_threshold))
-    Fgarbage_collect ();
+  maybe_gc ();
 
   if (++lisp_eval_depth > max_lisp_eval_depth)
     {

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2012-07-18 13:20:59 +0000
+++ b/src/keyboard.c    2012-07-20 05:28:00 +0000
@@ -2705,17 +2705,13 @@
              && ! CONSP (Vunread_command_events))
            {
              Fdo_auto_save (Qnil, Qnil);
-
-             /* If we have auto-saved and there is still no input
-                available, garbage collect if there has been enough
-                consing going on to make it worthwhile.  */
-             if (!detect_input_pending_run_timers (0)
-                 && consing_since_gc > gc_cons_threshold / 2)
-               Fgarbage_collect ();
-
              redisplay ();
            }
        }
+
+      /* If there is still no input available, ask for GC.  */
+      if (!detect_input_pending_run_timers (0))
+       maybe_gc ();
     }
 
   /* Notify the caller if an autosave hook, or a timer, sentinel or

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-07-19 03:55:59 +0000
+++ b/src/lisp.h        2012-07-20 05:28:00 +0000
@@ -2091,14 +2091,6 @@
 extern Lisp_Object Vascii_downcase_table;
 extern Lisp_Object Vascii_canon_table;
 
-/* Number of bytes of structure consed since last GC.  */
-
-extern EMACS_INT consing_since_gc;
-
-extern EMACS_INT gc_relative_threshold;
-
-extern EMACS_INT memory_full_cons_threshold;
-
 /* Structure for recording stack slots that need marking.  */
 
 /* This is a chain of structures, each of which points at a Lisp_Object
@@ -2601,6 +2593,7 @@
 #if defined REL_ALLOC && !defined SYSTEM_MALLOC
 extern void refill_memory_reserve (void);
 #endif
+extern void maybe_gc (void);
 extern const char *pending_malloc_warning;
 extern Lisp_Object zero_vector;
 extern Lisp_Object *stack_base;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]