diff options
| author | Dmitry Antipov | 2012-07-20 09:28:00 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-20 09:28:00 +0400 |
| commit | 765e61e391ee0937ff6b30510b6c4651064fe38e (patch) | |
| tree | 6f8cfef58d32ed81e2219fc69b1c5c5027c8cce8 /src/alloc.c | |
| parent | 89dea803ea4293eb8d14b87067d1e3eebdcbd180 (diff) | |
| download | emacs-765e61e391ee0937ff6b30510b6c4651064fe38e.tar.gz emacs-765e61e391ee0937ff6b30510b6c4651064fe38e.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/alloc.c b/src/alloc.c index 7158b45a340..36040f70b2d 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -166,16 +166,16 @@ struct emacs_globals globals; | |||
| 166 | 166 | ||
| 167 | /* Number of bytes of consing done since the last gc. */ | 167 | /* Number of bytes of consing done since the last gc. */ |
| 168 | 168 | ||
| 169 | EMACS_INT consing_since_gc; | 169 | static EMACS_INT consing_since_gc; |
| 170 | 170 | ||
| 171 | /* Similar minimum, computed from Vgc_cons_percentage. */ | 171 | /* Similar minimum, computed from Vgc_cons_percentage. */ |
| 172 | 172 | ||
| 173 | EMACS_INT gc_relative_threshold; | 173 | static EMACS_INT gc_relative_threshold; |
| 174 | 174 | ||
| 175 | /* Minimum number of bytes of consing since GC before next GC, | 175 | /* Minimum number of bytes of consing since GC before next GC, |
| 176 | when memory is full. */ | 176 | when memory is full. */ |
| 177 | 177 | ||
| 178 | EMACS_INT memory_full_cons_threshold; | 178 | static EMACS_INT memory_full_cons_threshold; |
| 179 | 179 | ||
| 180 | /* Nonzero during GC. */ | 180 | /* Nonzero during GC. */ |
| 181 | 181 | ||
| @@ -5374,6 +5374,18 @@ bounded_number (EMACS_INT number) | |||
| 5374 | return make_number (min (MOST_POSITIVE_FIXNUM, number)); | 5374 | return make_number (min (MOST_POSITIVE_FIXNUM, number)); |
| 5375 | } | 5375 | } |
| 5376 | 5376 | ||
| 5377 | /* Check whether it's time for GC, and run it if so. */ | ||
| 5378 | |||
| 5379 | void | ||
| 5380 | maybe_gc (void) | ||
| 5381 | { | ||
| 5382 | if ((consing_since_gc > gc_cons_threshold | ||
| 5383 | && consing_since_gc > gc_relative_threshold) | ||
| 5384 | || (!NILP (Vmemory_full) | ||
| 5385 | && consing_since_gc > memory_full_cons_threshold)) | ||
| 5386 | Fgarbage_collect (); | ||
| 5387 | } | ||
| 5388 | |||
| 5377 | DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", | 5389 | DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "", |
| 5378 | doc: /* Reclaim storage for Lisp objects no longer needed. | 5390 | doc: /* Reclaim storage for Lisp objects no longer needed. |
| 5379 | Garbage collection happens automatically if you cons more than | 5391 | Garbage collection happens automatically if you cons more than |