From dac616ff9f51b77e399a06863a79446958c4f840 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 20 Jul 2012 17:14:58 +0400 Subject: [PATCH] Make maybe_gc inline. Verify that inlining is always possible (GCC 4.7.1, -O3 -Winline). * lisp.h (consing_since_gc, gc_relative_threshold) (memory_full_cons_threshold): Revert declaration. (maybe_gc): Remove prototype, define as inline. * alloc.c: Remove old commented-out code. (consing_since_gc, gc_relative_threshold) (memory_full_cons_threshold): Revert to global. (maybe_gc): Remove. --- src/ChangeLog | 12 ++++++++++++ src/alloc.c | 21 +++------------------ src/lisp.h | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8242a35e9e..81122d4527 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2012-07-20 Dmitry Antipov + + Make maybe_gc inline. + Verify that inlining is always possible (GCC 4.7.1, -O3 -Winline). + * lisp.h (consing_since_gc, gc_relative_threshold) + (memory_full_cons_threshold): Revert declaration. + (maybe_gc): Remove prototype, define as inline. + * alloc.c: Remove old commented-out code. + (consing_since_gc, gc_relative_threshold) + (memory_full_cons_threshold): Revert to global. + (maybe_gc): Remove. + 2012-07-20 Dmitry Antipov Simple wrapper for make_unibyte_string, adjust font_open_by_name. diff --git a/src/alloc.c b/src/alloc.c index 36040f70b2..e7d67e95db 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -166,16 +166,16 @@ struct emacs_globals globals; /* Number of bytes of consing done since the last gc. */ -static EMACS_INT consing_since_gc; +EMACS_INT consing_since_gc; /* Similar minimum, computed from Vgc_cons_percentage. */ -static EMACS_INT gc_relative_threshold; +EMACS_INT gc_relative_threshold; /* Minimum number of bytes of consing since GC before next GC, when memory is full. */ -static EMACS_INT memory_full_cons_threshold; +EMACS_INT memory_full_cons_threshold; /* Nonzero during GC. */ @@ -5374,18 +5374,6 @@ 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 @@ -5474,8 +5462,6 @@ See Info node `(elisp)Garbage Collection'. */) gc_in_progress = 1; - /* clear_marks (); */ - /* Mark all the special slots that serve as the roots of accessibility. */ for (i = 0; i < staticidx; i++) @@ -5592,7 +5578,6 @@ See Info node `(elisp)Garbage Collection'. */) CHECK_CONS_LIST (); - /* clear_marks (); */ gc_in_progress = 0; consing_since_gc = 0; diff --git a/src/lisp.h b/src/lisp.h index 2a59890014..2f426c38fc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2593,10 +2593,12 @@ 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; +extern EMACS_INT consing_since_gc; +extern EMACS_INT gc_relative_threshold; +extern EMACS_INT memory_full_cons_threshold; extern Lisp_Object list1 (Lisp_Object); extern Lisp_Object list2 (Lisp_Object, Lisp_Object); extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object); @@ -3434,4 +3436,16 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); #include "globals.h" +/* Check whether it's time for GC, and run it if so. */ + +static inline 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 (); +} + #endif /* EMACS_LISP_H */ -- 2.20.1