Commit 765e61e3 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

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.
parent 89dea803
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'.
......
......@@ -166,16 +166,16 @@ struct emacs_globals globals;
/* 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 @@ bounded_number (EMACS_INT number)
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
......
......@@ -423,15 +423,11 @@ unmark_byte_stack (void)
/* 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. */
......
......@@ -2040,15 +2040,7 @@ eval_sub (Lisp_Object form)
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 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
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)
{
......
......@@ -2705,17 +2705,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
&& ! 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
......
......@@ -2091,14 +2091,6 @@ extern void process_quit_flag (void);
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 @@ extern void mark_object (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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment