From c752cfa916879f7415990855b52862dd585242ec Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 6 Sep 2012 13:15:44 +0400 Subject: [PATCH] Explicitly mark buffer_defaults and buffer_local_symbols. * alloc.c (Fgarbage_collect): Mark buffer_defaults and mark_local_symbols here. (mark_object): If GC_CHECK_MARKED_OBJECTS, simplify checking since special buffers aren't marked here any more. (allocate_buffer): Chain new buffer with all_buffers here... * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): ...and not here. (Vbuffer_defaults, Vbuffer_local_symbols): Remove. (syms_of_buffer): Remove staticpro of the above. (init_buffer_once): Set names for buffer_defaults and buffer_local_symbols. --- src/ChangeLog | 15 +++++++++++++++ src/alloc.c | 30 +++++++++++++++++------------- src/buffer.c | 22 +++------------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2ca75d416a..a017ef7fda 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2012-09-06 Dmitry Antipov + + Explicitly mark buffer_defaults and buffer_local_symbols. + * alloc.c (Fgarbage_collect): Mark buffer_defaults and + mark_local_symbols here. + (mark_object): If GC_CHECK_MARKED_OBJECTS, simplify checking + since special buffers aren't marked here any more. + (allocate_buffer): Chain new buffer with all_buffers here... + * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): ...and + not here. + (Vbuffer_defaults, Vbuffer_local_symbols): Remove. + (syms_of_buffer): Remove staticpro of the above. + (init_buffer_once): Set names for buffer_defaults and + buffer_local_symbols. + 2012-09-06 Paul Eggert Use bool for booleans in font-related modules. diff --git a/src/alloc.c b/src/alloc.c index aca0a82d1b..1a9718bcb2 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -278,6 +278,7 @@ static void gc_sweep (void); static Lisp_Object make_pure_vector (ptrdiff_t); static void mark_glyph_matrix (struct glyph_matrix *); static void mark_face_cache (struct face_cache *); +static void mark_buffer (struct buffer *); #if !defined REL_ALLOC || defined SYSTEM_MALLOC static void refill_memory_reserve (void); @@ -3281,7 +3282,10 @@ allocate_buffer (void) XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) - header_size) / word_size); - /* Note that the fields of B are not initialized. */ + /* Put B on the chain of all buffers including killed ones. */ + b->header.next.buffer = all_buffers; + all_buffers = b; + /* Note that the rest fields of B are not initialized. */ return b; } @@ -5473,6 +5477,9 @@ See Info node `(elisp)Garbage Collection'. */) /* Mark all the special slots that serve as the roots of accessibility. */ + mark_buffer (&buffer_defaults); + mark_buffer (&buffer_local_symbols); + for (i = 0; i < staticidx; i++) mark_object (*staticvec[i]); @@ -5950,9 +5957,7 @@ mark_object (Lisp_Object arg) #ifdef GC_CHECK_MARKED_OBJECTS m = mem_find (po); - if (m == MEM_NIL && !SUBRP (obj) - && po != &buffer_defaults - && po != &buffer_local_symbols) + if (m == MEM_NIL && !SUBRP (obj)) emacs_abort (); #endif /* GC_CHECK_MARKED_OBJECTS */ @@ -5969,15 +5974,14 @@ mark_object (Lisp_Object arg) { case PVEC_BUFFER: #ifdef GC_CHECK_MARKED_OBJECTS - if (po != &buffer_defaults && po != &buffer_local_symbols) - { - struct buffer *b; - FOR_EACH_BUFFER (b) - if (b == po) - break; - if (b == NULL) - emacs_abort (); - } + { + struct buffer *b; + FOR_EACH_BUFFER (b) + if (b == po) + break; + if (b == NULL) + emacs_abort (); + } #endif /* GC_CHECK_MARKED_OBJECTS */ mark_buffer ((struct buffer *) ptr); break; diff --git a/src/buffer.c b/src/buffer.c index 7698b72a3c..187277d663 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -60,10 +60,6 @@ struct buffer *all_buffers; struct buffer alignas (GCALIGNMENT) buffer_defaults; -/* A Lisp_Object pointer to the above, used for staticpro */ - -static Lisp_Object Vbuffer_defaults; - /* This structure marks which slots in a buffer have corresponding default values in buffer_defaults. Each such slot has a nonzero value in this structure. @@ -87,9 +83,6 @@ struct buffer buffer_local_flags; struct buffer alignas (GCALIGNMENT) buffer_local_symbols; -/* A Lisp_Object pointer to the above, used for staticpro */ -static Lisp_Object Vbuffer_local_symbols; - /* Return the symbol of the per-buffer variable at offset OFFSET in the buffer structure. */ @@ -595,10 +588,6 @@ even if it is dead. The return value is never nil. */) bset_width_table (b, Qnil); b->prevent_redisplay_optimizations_p = 1; - /* Put this on the chain of all buffers including killed ones. */ - b->header.next.buffer = all_buffers; - all_buffers = b; - /* An ordinary buffer normally doesn't need markers to handle BEGV and ZV. */ bset_pt_marker (b, Qnil); @@ -819,10 +808,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */) b->width_run_cache = 0; bset_width_table (b, Qnil); - /* Put this on the chain of all buffers including killed ones. */ - b->header.next.buffer = all_buffers; - all_buffers = b; - name = Fcopy_sequence (name); set_string_intervals (name, NULL); bset_name (b, name); @@ -5145,10 +5130,11 @@ init_buffer_once (void) buffer_local_symbols.indirections = 0; set_buffer_intervals (&buffer_defaults, NULL); set_buffer_intervals (&buffer_local_symbols, NULL); + /* This is not strictly necessary, but let's make them initialized. */ + bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*")); + bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*")); XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); - XSETBUFFER (Vbuffer_defaults, &buffer_defaults); XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); - XSETBUFFER (Vbuffer_local_symbols, &buffer_local_symbols); /* Set up the default values of various buffer slots. */ /* Must do these before making the first buffer! */ @@ -5430,8 +5416,6 @@ syms_of_buffer (void) last_overlay_modification_hooks = Fmake_vector (make_number (10), Qnil); - staticpro (&Vbuffer_defaults); - staticpro (&Vbuffer_local_symbols); staticpro (&Qfundamental_mode); staticpro (&Qmode_class); staticpro (&QSFundamental); -- 2.20.1