From: Dmitry Antipov <dmantipov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: martin rudalics <rudalics@gmx.at>, emacs-devel@gnu.org
Subject: Re: Reachable killed buffers
Date: Mon, 10 Sep 2012 19:15:58 +0400 [thread overview]
Message-ID: <504E042E.5040100@yandex.ru> (raw)
In-Reply-To: <jwvwr02hvhu.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
On 09/10/2012 05:25 PM, Stefan Monnier wrote:
> Hmm... how can we find those? I guess we could handle it during GC when
> we mark the BLV.
[...skip...]
> I think here as well the problem is how to find those windows, and again
> I think the easiest is to do it during GC.
Like this?
Dmitry
[-- Attachment #2: unref_killed_buffers.patch --]
[-- Type: text/plain, Size: 4056 bytes --]
=== modified file 'src/alloc.c'
--- src/alloc.c 2012-09-07 07:24:08 +0000
+++ src/alloc.c 2012-09-10 15:04:15 +0000
@@ -6009,6 +6009,12 @@
{
struct window *w = (struct window *) ptr;
+ /* Lisp code removes killed buffers from buffer lists
+ of live windows. For dead windows, we do it here
+ in attempt to help GC to reclaim killed buffers. */
+ if (!WINDOW_VALID_P (obj))
+ window_drain_buffer_lists (w);
+
mark_vectorlike (ptr);
/* Mark glyphs for leaf windows. Marking window
matrices is sufficient because frame matrices
@@ -6081,10 +6087,10 @@
case SYMBOL_LOCALIZED:
{
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (ptr);
- /* If the value is forwarded to a buffer or keyboard field,
- these are marked when we see the corresponding object.
- And if it's forwarded to a C variable, either it's not
- a Lisp_Object var, or it's staticpro'd already. */
+ /* If the value is set up for a killed buffer or deleted
+ frame, restore it's global binding. */
+ if (orphaned_local_binding (blv))
+ swap_in_global_binding (ptr);
mark_object (blv->where);
mark_object (blv->valcell);
mark_object (blv->defcell);
=== modified file 'src/data.c'
--- src/data.c 2012-09-09 16:06:33 +0000
+++ src/data.c 2012-09-10 15:11:42 +0000
@@ -1020,7 +1020,18 @@
store_symval_forwarding (blv->fwd, blv_value (blv), NULL);
}
}
-\f
+
+/* True if binding is set up for a killed buffer or deleted frame. */
+
+bool
+orphaned_local_binding (struct Lisp_Buffer_Local_Value *blv)
+{
+ Lisp_Object where = blv->where;
+
+ return ((BUFFERP (where) && NILP (BVAR (XBUFFER (where), name)))
+ || (FRAMEP (where) && !FRAME_LIVE_P (XFRAME (where))));
+}
+
/* Find the value of a symbol, returning Qunbound if it's not bound.
This is helpful for code which just wants to get a variable's value
if it has one, without signaling an error.
=== modified file 'src/lisp.h'
--- src/lisp.h 2012-09-10 01:17:23 +0000
+++ src/lisp.h 2012-09-10 14:26:18 +0000
@@ -2615,6 +2615,7 @@
extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object, bool);
extern void syms_of_data (void);
extern void init_data (void);
+extern bool orphaned_local_binding (struct Lisp_Buffer_Local_Value *);
extern void swap_in_global_binding (struct Lisp_Symbol *);
/* Defined in cmds.c */
=== modified file 'src/window.c'
--- src/window.c 2012-09-05 07:18:46 +0000
+++ src/window.c 2012-09-10 14:59:00 +0000
@@ -3002,7 +3002,42 @@
FOR_EACH_FRAME (tail, frame)
window_loop (REPLACE_BUFFER_IN_WINDOWS_SAFELY, buffer, 1, frame);
}
-\f
+
+/* Change alist started at ALISTPTR so it doesn't contains an items whose
+ car is a killed buffer. */
+
+static inline void
+delete_killed_buffers (Lisp_Object *alistptr)
+{
+ Lisp_Object tail, prev, buffer;
+
+ eassert (alistptr != NULL);
+ for (tail = *alistptr, prev = Qnil; CONSP (tail); tail = XCDR (tail))
+ {
+ buffer = CAR (XCAR (tail));
+ CHECK_BUFFER (buffer);
+ if (NILP (BVAR (XBUFFER (buffer), name)))
+ {
+ if (NILP (prev))
+ *alistptr = XCDR (tail);
+ else
+ XSETCDR (prev, XCDR (tail));
+ }
+ else
+ prev = tail;
+ }
+}
+
+/* Delete killed buffers from both W's window lists. Called during GC
+ for dead windows only. */
+
+void
+window_drain_buffer_lists (struct window *w)
+{
+ delete_killed_buffers (&w->prev_buffers);
+ delete_killed_buffers (&w->next_buffers);
+}
+
/* If *ROWS or *COLS are too small a size for FRAME, set them to the
minimum allowable size. */
=== modified file 'src/window.h'
--- src/window.h 2012-09-05 17:05:32 +0000
+++ src/window.h 2012-09-10 14:59:27 +0000
@@ -978,6 +978,7 @@
extern void temp_output_buffer_show (Lisp_Object);
extern void replace_buffer_in_windows (Lisp_Object);
extern void replace_buffer_in_windows_safely (Lisp_Object);
+extern void window_drain_buffer_lists (struct window *);
extern void init_window_once (void);
extern void init_window (void);
extern void syms_of_window (void);
next prev parent reply other threads:[~2012-09-10 15:15 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1T9II0-0005q4-Gh@vcs.savannah.gnu.org>
2012-09-05 18:24 ` [Emacs-diffs] /srv/bzr/emacs/trunk r109890: Do not mark objects from deleted buffers, windows and frames Stefan Monnier
2012-09-05 19:15 ` Stefan Monnier
2012-09-06 6:55 ` Dmitry Antipov
2012-09-06 7:00 ` Herring, Davis
2012-09-06 7:28 ` martin rudalics
2012-09-06 9:57 ` Dmitry Antipov
2012-09-06 14:42 ` martin rudalics
2012-09-06 12:53 ` Stefan Monnier
2012-09-06 14:42 ` martin rudalics
2012-09-06 12:52 ` Stefan Monnier
2012-09-06 14:42 ` martin rudalics
2012-09-06 17:33 ` Stefan Monnier
2012-09-07 9:52 ` martin rudalics
2012-09-06 17:06 ` Dmitry Antipov
2012-09-06 17:37 ` Stefan Monnier
2012-09-07 9:53 ` martin rudalics
2012-09-07 15:19 ` Stefan Monnier
2012-09-10 9:46 ` Reachable killed buffers [Was: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109890: Do not mark objects from deleted buffers, windows and frames] Dmitry Antipov
2012-09-10 13:25 ` Stefan Monnier
2012-09-10 15:15 ` Dmitry Antipov [this message]
2012-09-10 20:15 ` Reachable killed buffers Stefan Monnier
2012-09-10 21:10 ` Stefan Monnier
2012-09-11 5:25 ` Dmitry Antipov
2012-09-11 13:06 ` Stefan Monnier
2012-09-12 8:09 ` martin rudalics
2012-09-12 13:47 ` Paul Eggert
2012-09-12 13:59 ` Dmitry Antipov
2012-09-12 14:05 ` Paul Eggert
2012-09-12 14:15 ` martin rudalics
2012-09-12 15:59 ` Dmitry Antipov
2012-09-12 17:37 ` martin rudalics
2012-09-12 17:55 ` Paul Eggert
2012-09-13 3:29 ` Stefan Monnier
2012-09-13 4:43 ` Paul Eggert
2012-09-13 5:00 ` Dmitry Antipov
2012-09-13 5:18 ` Paul Eggert
2012-09-13 12:47 ` Stefan Monnier
2012-09-13 16:49 ` martin rudalics
2012-09-13 17:11 ` Paul Eggert
2012-09-13 17:30 ` martin rudalics
2012-09-14 12:10 ` Dmitry Antipov
2012-09-14 13:29 ` Stefan Monnier
2012-09-14 13:38 ` martin rudalics
2012-09-13 18:01 ` Dmitry Antipov
2012-09-06 7:20 ` [Emacs-diffs] /srv/bzr/emacs/trunk r109890: Do not mark objects from deleted buffers, windows and frames martin rudalics
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=504E042E.5040100@yandex.ru \
--to=dmantipov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.