From bf2d92f6387e7bade0567f2081b420084e13b502 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 14 Mar 2020 18:26:33 +0000 Subject: [PATCH] Don't collect reachable killed buffers during GC * src/alloc.c (live_buffer_holding): Add `all_buffers' argument for returning killed buffers. (mark_maybe_object, mark_maybe_pointer): Use it. --- src/alloc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 1c6b664b22..aea1f27a39 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4482,20 +4482,22 @@ live_vector_p (struct mem_node *m, void *p) } /* If P is a pointer into a live buffer, return the buffer. - Otherwise, return nil. M is a pointer to the mem_block for P. */ + Otherwise, return nil. M is a pointer to the mem_block for P. + Also return killed buffers if ALL-BUFFERS is true. */ static Lisp_Object -live_buffer_holding (struct mem_node *m, void *p) +live_buffer_holding (struct mem_node *m, void *p, bool all_buffers) { - /* P must point into the block, and the buffer - must not have been killed. */ + /* P must point into the block, and the buffer must not + have been killed unless ALL-BUFFERS is true. */ if (m->type == MEM_TYPE_BUFFER) { struct buffer *b = m->start; char *cb = m->start; char *cp = p; ptrdiff_t offset = cp - cb; - if (0 <= offset && offset < sizeof *b && !NILP (b->name_)) + if (0 <= offset && offset < sizeof *b && + (all_buffers || !NILP (b->name_))) { Lisp_Object obj; XSETBUFFER (obj, b); @@ -4508,7 +4510,7 @@ live_buffer_holding (struct mem_node *m, void *p) static bool live_buffer_p (struct mem_node *m, void *p) { - return !NILP (live_buffer_holding (m, p)); + return !NILP (live_buffer_holding (m, p, false)); } /* Mark OBJ if we can prove it's a Lisp_Object. */ @@ -4566,7 +4568,7 @@ mark_maybe_object (Lisp_Object obj) case Lisp_Vectorlike: mark_p = (EQ (obj, live_vector_holding (m, po)) - || EQ (obj, live_buffer_holding (m, po))); + || EQ (obj, live_buffer_holding (m, po, true))); break; default: @@ -4636,7 +4638,7 @@ mark_maybe_pointer (void *p) break; case MEM_TYPE_BUFFER: - obj = live_buffer_holding (m, p); + obj = live_buffer_holding (m, p, true); break; case MEM_TYPE_CONS: -- 2.25.1