From: Dmitry Antipov Date: Thu, 13 Sep 2012 05:18:26 +0000 (+0400) Subject: Function to mark objects and remove killed buffers at once. X-Git-Tag: emacs-24.2.90~294 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d59a1afb9acc881201223e7c573e94526b3cd3fc;p=emacs.git Function to mark objects and remove killed buffers at once. * alloc.c (discard_killed_buffers): Rename to ... (mark_discard_killed buffers) ... new name. Add marking of remaining objects. Fix comment. Adjust users. (mark_object): Do not touch frame buffer lists here. * frame.c (delete_frame): Reset frame buffer lists here. --- diff --git a/src/ChangeLog b/src/ChangeLog index 2bc041f0435..90f3fc33b59 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-09-13 Dmitry Antipov + + Function to mark objects and remove killed buffers at once. + * alloc.c (discard_killed_buffers): Rename to ... + (mark_discard_killed buffers) ... new name. Add marking + of remaining objects. Fix comment. Adjust users. + (mark_object): Do not touch frame buffer lists here. + * frame.c (delete_frame): Reset frame buffer lists here. + 2012-09-13 Paul Eggert Better workaround for GNOME bug when --enable-gcc-warnings. diff --git a/src/alloc.c b/src/alloc.c index 61cb7086c25..77807f6e086 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5865,16 +5865,16 @@ mark_buffer (struct buffer *buffer) mark_buffer (buffer->base_buffer); } -/* Remove killed buffers or items whose car is a killed buffer - from LIST and return changed LIST. Called during GC. */ +/* Remove killed buffers or items whose car is a killed buffer from + LIST, and mark other items. Return changed LIST, which is marked. */ static Lisp_Object -discard_killed_buffers (Lisp_Object list) +mark_discard_killed_buffers (Lisp_Object list) { - Lisp_Object *prev = &list; - Lisp_Object tail; + Lisp_Object tail, *prev = &list; - for (tail = list; CONSP (tail); tail = XCDR (tail)) + for (tail = list; CONSP (tail) && !CONS_MARKED_P (XCONS (tail)); + tail = XCDR (tail)) { Lisp_Object tem = XCAR (tail); if (CONSP (tem)) @@ -5882,7 +5882,11 @@ discard_killed_buffers (Lisp_Object list) if (BUFFERP (tem) && !BUFFER_LIVE_P (XBUFFER (tem))) *prev = XCDR (tail); else - prev = &XCDR_AS_LVALUE (tail); + { + CONS_MARK (XCONS (tail)); + mark_object (XCAR (tail)); + prev = &XCDR_AS_LVALUE (tail); + } } return list; } @@ -6023,18 +6027,8 @@ mark_object (Lisp_Object arg) break; case PVEC_FRAME: - { - struct frame *f = (struct frame *) ptr; - - /* For live frames, killed buffers are filtered out by - store_frame_param. For dead frames, we do it here in - attempt to help GC to reclaim killed buffers faster. */ - if (!FRAME_LIVE_P (f)) - fset_buffer_list (f, discard_killed_buffers (f->buffer_list)); - - mark_vectorlike (ptr); - mark_face_cache (f->face_cache); - } + mark_vectorlike (ptr); + mark_face_cache (((struct frame *) ptr)->face_cache); break; case PVEC_WINDOW: @@ -6048,9 +6042,9 @@ mark_object (Lisp_Object arg) if (leaf && NILP (w->buffer)) { wset_prev_buffers - (w, discard_killed_buffers (w->prev_buffers)); + (w, mark_discard_killed_buffers (w->prev_buffers)); wset_next_buffers - (w, discard_killed_buffers (w->next_buffers)); + (w, mark_discard_killed_buffers (w->next_buffers)); } mark_vectorlike (ptr); diff --git a/src/frame.c b/src/frame.c index 9b12842bf89..d10969692ee 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1299,6 +1299,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force) structures can still refer to it. */ fset_menu_bar_vector (f, Qnil); + /* If FRAME's buffer lists contains killed + buffers, this helps GC to reclaim them. */ + fset_buffer_list (f, Qnil); + fset_buried_buffer_list (f, Qnil); + free_font_driver_list (f); xfree (f->namebuf); xfree (f->decode_mode_spec_buffer);