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 | |
| 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')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/alloc.c | 18 | ||||
| -rw-r--r-- | src/bytecode.c | 14 | ||||
| -rw-r--r-- | src/eval.c | 16 | ||||
| -rw-r--r-- | src/keyboard.c | 12 | ||||
| -rw-r--r-- | src/lisp.h | 9 |
6 files changed, 41 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index bed8e25ab77..909fb03c488 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2012-07-20 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Cleanup calls to Fgarbage_collect. | ||
| 4 | * lisp.h (maybe_gc): New prototype. | ||
| 5 | (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): | ||
| 6 | Remove declarations. | ||
| 7 | * alloc.c (maybe_gc): New function. | ||
| 8 | (consing_since_gc, gc_relative_threshold, memory_full_cons_threshold): | ||
| 9 | Make them static. | ||
| 10 | * bytecode.c (MAYBE_GC): Use maybe_gc. | ||
| 11 | * eval.c (eval_sub, Ffuncall): Likewise. | ||
| 12 | * keyboard.c (read_char): Likewise. Adjust call to maybe_gc | ||
| 13 | to avoid dependency from auto-save feature. | ||
| 14 | |||
| 1 | 2012-07-19 Paul Eggert <eggert@cs.ucla.edu> | 15 | 2012-07-19 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 16 | ||
| 3 | * buffer.h (FOR_EACH_BUFFER): Rename from 'for_each_buffer'. | 17 | * buffer.h (FOR_EACH_BUFFER): Rename from 'for_each_buffer'. |
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 |
diff --git a/src/bytecode.c b/src/bytecode.c index acdf809971f..dca1e552dd0 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -423,15 +423,11 @@ unmark_byte_stack (void) | |||
| 423 | /* Garbage collect if we have consed enough since the last time. | 423 | /* Garbage collect if we have consed enough since the last time. |
| 424 | We do this at every branch, to avoid loops that never GC. */ | 424 | We do this at every branch, to avoid loops that never GC. */ |
| 425 | 425 | ||
| 426 | #define MAYBE_GC() \ | 426 | #define MAYBE_GC() \ |
| 427 | do { \ | 427 | do { \ |
| 428 | if (consing_since_gc > gc_cons_threshold \ | 428 | BEFORE_POTENTIAL_GC (); \ |
| 429 | && consing_since_gc > gc_relative_threshold) \ | 429 | maybe_gc (); \ |
| 430 | { \ | 430 | AFTER_POTENTIAL_GC (); \ |
| 431 | BEFORE_POTENTIAL_GC (); \ | ||
| 432 | Fgarbage_collect (); \ | ||
| 433 | AFTER_POTENTIAL_GC (); \ | ||
| 434 | } \ | ||
| 435 | } while (0) | 431 | } while (0) |
| 436 | 432 | ||
| 437 | /* Check for jumping out of range. */ | 433 | /* Check for jumping out of range. */ |
diff --git a/src/eval.c b/src/eval.c index da567e1e635..a0143c372de 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -2040,15 +2040,7 @@ eval_sub (Lisp_Object form) | |||
| 2040 | return form; | 2040 | return form; |
| 2041 | 2041 | ||
| 2042 | QUIT; | 2042 | QUIT; |
| 2043 | if ((consing_since_gc > gc_cons_threshold | 2043 | maybe_gc (); |
| 2044 | && consing_since_gc > gc_relative_threshold) | ||
| 2045 | || | ||
| 2046 | (!NILP (Vmemory_full) && consing_since_gc > memory_full_cons_threshold)) | ||
| 2047 | { | ||
| 2048 | GCPRO1 (form); | ||
| 2049 | Fgarbage_collect (); | ||
| 2050 | UNGCPRO; | ||
| 2051 | } | ||
| 2052 | 2044 | ||
| 2053 | if (++lisp_eval_depth > max_lisp_eval_depth) | 2045 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| 2054 | { | 2046 | { |
| @@ -2737,11 +2729,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) | |||
| 2737 | ptrdiff_t i; | 2729 | ptrdiff_t i; |
| 2738 | 2730 | ||
| 2739 | QUIT; | 2731 | QUIT; |
| 2740 | if ((consing_since_gc > gc_cons_threshold | 2732 | maybe_gc (); |
| 2741 | && consing_since_gc > gc_relative_threshold) | ||
| 2742 | || | ||
| 2743 | (!NILP (Vmemory_full) && consing_since_gc > memory_full_cons_threshold)) | ||
| 2744 | Fgarbage_collect (); | ||
| 2745 | 2733 | ||
| 2746 | if (++lisp_eval_depth > max_lisp_eval_depth) | 2734 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| 2747 | { | 2735 | { |
diff --git a/src/keyboard.c b/src/keyboard.c index 9f3bc478447..5e6dca64a92 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2705,17 +2705,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2705 | && ! CONSP (Vunread_command_events)) | 2705 | && ! CONSP (Vunread_command_events)) |
| 2706 | { | 2706 | { |
| 2707 | Fdo_auto_save (Qnil, Qnil); | 2707 | Fdo_auto_save (Qnil, Qnil); |
| 2708 | |||
| 2709 | /* If we have auto-saved and there is still no input | ||
| 2710 | available, garbage collect if there has been enough | ||
| 2711 | consing going on to make it worthwhile. */ | ||
| 2712 | if (!detect_input_pending_run_timers (0) | ||
| 2713 | && consing_since_gc > gc_cons_threshold / 2) | ||
| 2714 | Fgarbage_collect (); | ||
| 2715 | |||
| 2716 | redisplay (); | 2708 | redisplay (); |
| 2717 | } | 2709 | } |
| 2718 | } | 2710 | } |
| 2711 | |||
| 2712 | /* If there is still no input available, ask for GC. */ | ||
| 2713 | if (!detect_input_pending_run_timers (0)) | ||
| 2714 | maybe_gc (); | ||
| 2719 | } | 2715 | } |
| 2720 | 2716 | ||
| 2721 | /* Notify the caller if an autosave hook, or a timer, sentinel or | 2717 | /* Notify the caller if an autosave hook, or a timer, sentinel or |
diff --git a/src/lisp.h b/src/lisp.h index bfdc4ea4c07..471b8277b82 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2091,14 +2091,6 @@ extern void process_quit_flag (void); | |||
| 2091 | extern Lisp_Object Vascii_downcase_table; | 2091 | extern Lisp_Object Vascii_downcase_table; |
| 2092 | extern Lisp_Object Vascii_canon_table; | 2092 | extern Lisp_Object Vascii_canon_table; |
| 2093 | 2093 | ||
| 2094 | /* Number of bytes of structure consed since last GC. */ | ||
| 2095 | |||
| 2096 | extern EMACS_INT consing_since_gc; | ||
| 2097 | |||
| 2098 | extern EMACS_INT gc_relative_threshold; | ||
| 2099 | |||
| 2100 | extern EMACS_INT memory_full_cons_threshold; | ||
| 2101 | |||
| 2102 | /* Structure for recording stack slots that need marking. */ | 2094 | /* Structure for recording stack slots that need marking. */ |
| 2103 | 2095 | ||
| 2104 | /* This is a chain of structures, each of which points at a Lisp_Object | 2096 | /* This is a chain of structures, each of which points at a Lisp_Object |
| @@ -2601,6 +2593,7 @@ extern void mark_object (Lisp_Object); | |||
| 2601 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC | 2593 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC |
| 2602 | extern void refill_memory_reserve (void); | 2594 | extern void refill_memory_reserve (void); |
| 2603 | #endif | 2595 | #endif |
| 2596 | extern void maybe_gc (void); | ||
| 2604 | extern const char *pending_malloc_warning; | 2597 | extern const char *pending_malloc_warning; |
| 2605 | extern Lisp_Object zero_vector; | 2598 | extern Lisp_Object zero_vector; |
| 2606 | extern Lisp_Object *stack_base; | 2599 | extern Lisp_Object *stack_base; |