* 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-20 Dmitry Antipov <dmantipov@yandex.ru>
+
+ 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 <eggert@cs.ucla.edu>
* buffer.h (FOR_EACH_BUFFER): Rename from 'for_each_buffer'.
/* 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. */
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
/* 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. */
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)
{
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)
{
&& ! 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
extern Lisp_Object Vascii_downcase_table;
extern Lisp_Object Vascii_canon_table;
\f
-/* 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
#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;