From af26b72c1187a93cdacc6abb6561f3c331346cef Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 3 Sep 2012 23:34:19 -0700 Subject: Be more systematic about _setjmp vs setjmp. * alloc.c (test_setjmp, mark_stack): * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]: (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]: (png_load, my_error_exit, jpeg_load): * process.c (send_process_trap, send_process): Uniformly prefer _setjmp and _longjmp to setjmp and longjmp. The underscored versions are up to 30x faster on some hosts. Formerly, the code used setjmp+longjmp sometimes and _setjmp+_longjmp at other times, with no particular reason to prefer setjmp+longjmp. --- src/alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 188a514376d..edecd51f1ac 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4764,7 +4764,7 @@ test_setjmp (void) x = strlen (buf); x = 2 * x - 1; - setjmp (jbuf); + _setjmp (jbuf); if (longjmps_done == 1) { /* Came here after the longjmp at the end of the function. @@ -4789,7 +4789,7 @@ test_setjmp (void) ++longjmps_done; x = 2; if (longjmps_done == 1) - longjmp (jbuf, 1); + _longjmp (jbuf, 1); } #endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ @@ -4931,7 +4931,7 @@ mark_stack (void) } #endif /* GC_SETJMP_WORKS */ - setjmp (j.j); + _setjmp (j.j); end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; #endif /* not GC_SAVE_REGISTERS_ON_STACK */ #endif /* not HAVE___BUILTIN_UNWIND_INIT */ -- cgit v1.2.1 From 1088b9226e7dac7314dab52ef0696a5f540900cd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 4 Sep 2012 10:34:54 -0700 Subject: Simplify redefinition of 'abort' (Bug#12316). Do not try to redefine the 'abort' function. Instead, redo the code so that it calls 'emacs_abort' rather than 'abort'. This removes the need for the NO_ABORT configure-time macro and makes it easier to change the abort code to do a backtrace. * configure.ac (NO_ABRT): Remove. * admin/CPP-DEFINES (NO_ABORT): Remove. * nt/inc/ms-w32.h (w32_abort) [HAVE_NTGUI]: Remove. * src/.gdbinit: Just stop at emacs_abort, not at w32_abort or abort. * src/emacs.c (abort) [!DOS_NT && !NO_ABORT]: Remove; sysdep.c's emacs_abort now takes its place. * src/lisp.h (emacs_abort): New decl. All calls from Emacs code to 'abort' changed to use 'emacs_abort'. * src/msdos.c (dos_abort) [defined abort]: Remove; not used. (abort) [!defined abort]: Rename to ... (emacs_abort): ... new name. * src/sysdep.c (emacs_abort) [!HAVE_NTGUI]: New function, taking the place of the old 'abort' in emacs.c. * src/w32.c, src/w32fns.c (abort): Do not #undef. * src/w32.c (emacs_abort): Rename from w32_abort. --- src/alloc.c | 64 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index edecd51f1ac..2a831cea62a 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -613,7 +613,7 @@ overrun_check_malloc (size_t size) register unsigned char *val; int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; if (SIZE_MAX - overhead < size) - abort (); + emacs_abort (); val = malloc (size + overhead); if (val && check_depth == 1) @@ -638,7 +638,7 @@ overrun_check_realloc (void *block, size_t size) register unsigned char *val = (unsigned char *) block; int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; if (SIZE_MAX - overhead < size) - abort (); + emacs_abort (); if (val && check_depth == 1 @@ -649,7 +649,7 @@ overrun_check_realloc (void *block, size_t size) size_t osize = xmalloc_get_size (val); if (memcmp (xmalloc_overrun_check_trailer, val + osize, XMALLOC_OVERRUN_CHECK_SIZE)) - abort (); + emacs_abort (); memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); @@ -686,7 +686,7 @@ overrun_check_free (void *block) size_t osize = xmalloc_get_size (val); if (memcmp (xmalloc_overrun_check_trailer, val + osize, XMALLOC_OVERRUN_CHECK_SIZE)) - abort (); + emacs_abort (); #ifdef XMALLOC_CLEAR_FREE_MEMORY val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD); @@ -1272,7 +1272,7 @@ emacs_blocked_free (void *ptr, const void *ptr2) { fprintf (stderr, "Freeing `%p' which wasn't allocated with malloc\n", ptr); - abort (); + emacs_abort (); } else { @@ -1331,7 +1331,7 @@ emacs_blocked_malloc (size_t size, const void *ptr) fprintf (stderr, "Region in use is %p...%p, %td bytes, type %d\n", m->start, m->end, (char *) m->end - (char *) m->start, m->type); - abort (); + emacs_abort (); } if (!dont_register_blocks) @@ -1369,7 +1369,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) fprintf (stderr, "Realloc of %p which wasn't allocated with malloc\n", ptr); - abort (); + emacs_abort (); } mem_delete (m); @@ -1391,7 +1391,7 @@ emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2) if (m != MEM_NIL) { fprintf (stderr, "Realloc returns memory that is already in use\n"); - abort (); + emacs_abort (); } /* Can't handle zero size regions in the red-black tree. */ @@ -1804,7 +1804,7 @@ string_bytes (struct Lisp_String *s) if (!PURE_POINTER_P (s) && s->data && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s))) - abort (); + emacs_abort (); return nbytes; } @@ -1878,7 +1878,7 @@ check_string_free_list (void) while (s != NULL) { if ((uintptr_t) s < 1024) - abort (); + emacs_abort (); s = NEXT_FREE_LISP_STRING (s); } } @@ -2107,7 +2107,7 @@ sweep_strings (void) back-pointer so that we know it's free. */ #ifdef GC_CHECK_STRING_BYTES if (string_bytes (s) != SDATA_NBYTES (data)) - abort (); + emacs_abort (); #else data->u.nbytes = STRING_BYTES (s); #endif @@ -2218,7 +2218,7 @@ compact_small_strings (void) /* Check that the string size recorded in the string is the same as the one recorded in the sdata structure. */ if (s && string_bytes (s) != SDATA_NBYTES (from)) - abort (); + emacs_abort (); #endif /* GC_CHECK_STRING_BYTES */ nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); @@ -2231,7 +2231,7 @@ compact_small_strings (void) if (memcmp (string_overrun_cookie, (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE, GC_STRING_OVERRUN_COOKIE_SIZE)) - abort (); + emacs_abort (); #endif /* Non-NULL S means it's alive. Copy its data. */ @@ -2488,7 +2488,7 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes) struct Lisp_String *s; if (nchars < 0) - abort (); + emacs_abort (); if (!nbytes) return empty_multibyte_string; @@ -2809,7 +2809,7 @@ listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...) else if (type == CONSTYPE_HEAP) val = Fcons (objp[i], val); else - abort (); + emacs_abort (); } return val; } @@ -3919,7 +3919,7 @@ mem_insert (void *start, void *end, enum mem_type type) while (c != MEM_NIL) { if (start >= c->start && start < c->end) - abort (); + emacs_abort (); parent = c; c = start < c->start ? c->left : c->right; } @@ -3938,7 +3938,7 @@ mem_insert (void *start, void *end, enum mem_type type) #ifdef GC_MALLOC_CHECK x = _malloc_internal (sizeof *x); if (x == NULL) - abort (); + emacs_abort (); #else x = xmalloc (sizeof *x); #endif @@ -4613,7 +4613,7 @@ mark_maybe_pointer (void *p) break; default: - abort (); + emacs_abort (); } if (!NILP (obj)) @@ -4810,7 +4810,7 @@ check_gcpros (void) if (!survives_gc_p (p->var[i])) /* FIXME: It's not necessarily a bug. It might just be that the GCPRO is unnecessary or should release the object sooner. */ - abort (); + emacs_abort (); } #elif GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES @@ -5351,7 +5351,7 @@ staticpro (Lisp_Object *varaddress) { staticvec[staticidx++] = varaddress; if (staticidx >= NSTATICS) - abort (); + emacs_abort (); } @@ -5406,7 +5406,7 @@ See Info node `(elisp)Garbage Collection'. */) Lisp_Object retval = Qnil; if (abort_on_gc) - abort (); + emacs_abort (); /* Can't GC if pure storage overflowed because we can't determine if something is a pure object or not. */ @@ -5887,7 +5887,7 @@ mark_object (Lisp_Object arg) do { \ m = mem_find (po); \ if (m == MEM_NIL) \ - abort (); \ + emacs_abort (); \ } while (0) /* Check that the object pointed to by PO is live, using predicate @@ -5895,7 +5895,7 @@ mark_object (Lisp_Object arg) #define CHECK_LIVE(LIVEP) \ do { \ if (!LIVEP (m, po)) \ - abort (); \ + emacs_abort (); \ } while (0) /* Check both of the above conditions. */ @@ -5943,7 +5943,7 @@ mark_object (Lisp_Object arg) if (m == MEM_NIL && !SUBRP (obj) && po != &buffer_defaults && po != &buffer_local_symbols) - abort (); + emacs_abort (); #endif /* GC_CHECK_MARKED_OBJECTS */ if (ptr->header.size & PSEUDOVECTOR_FLAG) @@ -5966,7 +5966,7 @@ mark_object (Lisp_Object arg) if (b == po) break; if (b == NULL) - abort (); + emacs_abort (); } #endif /* GC_CHECK_MARKED_OBJECTS */ mark_buffer ((struct buffer *) ptr); @@ -6042,7 +6042,7 @@ mark_object (Lisp_Object arg) break; case PVEC_FREE: - abort (); + emacs_abort (); default: mark_vectorlike (ptr); @@ -6089,7 +6089,7 @@ mark_object (Lisp_Object arg) And if it's forwarded to a C variable, either it's not a Lisp_Object var, or it's staticpro'd already. */ break; - default: abort (); + default: emacs_abort (); } if (!PURE_POINTER_P (XSTRING (ptr->name))) MARK_STRING (XSTRING (ptr->name)); @@ -6143,7 +6143,7 @@ mark_object (Lisp_Object arg) break; default: - abort (); + emacs_abort (); } break; @@ -6165,7 +6165,7 @@ mark_object (Lisp_Object arg) obj = ptr->u.cdr; cdr_count++; if (cdr_count == mark_object_loop_halt) - abort (); + emacs_abort (); goto loop; } @@ -6178,7 +6178,7 @@ mark_object (Lisp_Object arg) break; default: - abort (); + emacs_abort (); } #undef CHECK_LIVE @@ -6247,7 +6247,7 @@ survives_gc_p (Lisp_Object obj) break; default: - abort (); + emacs_abort (); } return survives_p || PURE_POINTER_P ((void *) XPNTR (obj)); @@ -6699,7 +6699,7 @@ die (const char *msg, const char *file, int line) file, line, msg); npointers = backtrace (buffer, NPOINTERS_MAX); backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); - abort (); + emacs_abort (); } #endif -- cgit v1.2.1 From cf29dd84d205e1c78fed5d1ea0006a382658598c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 4 Sep 2012 11:29:04 -0700 Subject: Give more-useful info on a fatal error (Bug#12328). * doc/emacs/trouble.texi (Crashing): New section, documenting this. * etc/NEWS: Document the change. * src/alloc.c [ENABLE_CHECKING]: Do not include . (die) [ENABLE_CHECKING]: Call fatal_error_backtrace instead of doing the work ourselves. * src/emacs.c (fatal_error_signal): Let fatal_error_backtrace do most of the work. (fatal_error_backtrace): New function, taken from the guts of the old fatal_error_signal, but with a new option to output a backtrace. (shut_down_emacs) [!DOS_NT]: Use strsignal to give more-useful info about the signal than just its number. * src/lisp.h (fatal_error_backtrace, emacs_backtrace): New decls. * src/sysdep.c: Include (emacs_backtrace): New function, taken partly from the previous code of the 'die' function. (emacs_abort): Call fatal_error_backtrace rather than abort. --- src/alloc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 2a831cea62a..157d3a1d799 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6685,21 +6685,14 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max) #ifdef ENABLE_CHECKING -# include - bool suppress_checking; void die (const char *msg, const char *file, int line) { - enum { NPOINTERS_MAX = 500 }; - void *buffer[NPOINTERS_MAX]; - int npointers; fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n", file, line, msg); - npointers = backtrace (buffer, NPOINTERS_MAX); - backtrace_symbols_fd (buffer, npointers, STDERR_FILENO); - emacs_abort (); + fatal_error_backtrace (SIGABRT, INT_MAX); } #endif -- cgit v1.2.1 From c1ca42cae6eb3f13b0bf513c7131778cba228b8a Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 5 Sep 2012 16:55:03 +0400 Subject: * alloc.c (valid_lisp_object_p): Treat killed buffers, buffer_defaults and buffer_local_symbols as valid objects. Return special value to denote them. --- src/alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 157d3a1d799..80ab2d2cb97 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4981,7 +4981,8 @@ valid_pointer_p (void *p) #endif } -/* Return 1 if OBJ is a valid lisp object. +/* Return 2 if OBJ is a killed or special buffer object. + Return 1 if OBJ is a valid lisp object. Return 0 if OBJ is NOT a valid lisp object. Return -1 if we cannot validate OBJ. This function can be quite slow, @@ -5002,6 +5003,9 @@ valid_lisp_object_p (Lisp_Object obj) if (PURE_POINTER_P (p)) return 1; + if (p == &buffer_defaults || p == &buffer_local_symbols) + return 2; + #if !GC_MARK_STACK return valid_pointer_p (p); #else @@ -5027,7 +5031,7 @@ valid_lisp_object_p (Lisp_Object obj) return 0; case MEM_TYPE_BUFFER: - return live_buffer_p (m, p); + return live_buffer_p (m, p) ? 1 : 2; case MEM_TYPE_CONS: return live_cons_p (m, p); -- cgit v1.2.1 From 697e1e393c9cd70acf35da9700a25b6367b7da40 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 5 Sep 2012 19:34:45 +0400 Subject: Do not mark objects from deleted buffers, windows and frames. * alloc.c (mark_buffer): Mark just the buffer if it is dead. (mark_object): Likewise for windows and frames. --- src/alloc.c | 64 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 80ab2d2cb97..e90cca637df 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5838,23 +5838,29 @@ mark_overlay (struct Lisp_Overlay *ptr) static void mark_buffer (struct buffer *buffer) { - /* This is handled much like other pseudovectors... */ - mark_vectorlike ((struct Lisp_Vector *) buffer); + if (NILP (BVAR (buffer, name))) + /* If the buffer is killed, mark just the buffer itself. */ + VECTOR_MARK (buffer); + else + { + /* This is handled much like other pseudovectors... */ + mark_vectorlike ((struct Lisp_Vector *) buffer); - /* ...but there are some buffer-specific things. */ + /* ...but there are some buffer-specific things. */ - MARK_INTERVAL_TREE (buffer_intervals (buffer)); + MARK_INTERVAL_TREE (buffer_intervals (buffer)); - /* For now, we just don't mark the undo_list. It's done later in - a special way just before the sweep phase, and after stripping - some of its elements that are not needed any more. */ + /* For now, we just don't mark the undo_list. It's done later in + a special way just before the sweep phase, and after stripping + some of its elements that are not needed any more. */ - mark_overlay (buffer->overlays_before); - mark_overlay (buffer->overlays_after); + mark_overlay (buffer->overlays_before); + mark_overlay (buffer->overlays_after); - /* If this is an indirect buffer, mark its base buffer. */ - if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) - mark_buffer (buffer->base_buffer); + /* If this is an indirect buffer, mark its base buffer. */ + if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) + mark_buffer (buffer->base_buffer); + } } /* Determine type of generic Lisp_Object and mark it accordingly. */ @@ -5997,24 +6003,38 @@ mark_object (Lisp_Object arg) case PVEC_FRAME: { - mark_vectorlike (ptr); - mark_face_cache (((struct frame *) ptr)->face_cache); + struct frame *f = (struct frame *) ptr; + + if (FRAME_LIVE_P (f)) + { + mark_vectorlike (ptr); + mark_face_cache (f->face_cache); + } + else + /* If the frame is deleted, mark just the frame itself. */ + VECTOR_MARK (ptr); } break; case PVEC_WINDOW: { struct window *w = (struct window *) ptr; + bool leaf = NILP (w->hchild) && NILP (w->vchild); - mark_vectorlike (ptr); - /* Mark glyphs for leaf windows. Marking window - matrices is sufficient because frame matrices - use the same glyph memory. */ - if (NILP (w->hchild) && NILP (w->vchild) - && w->current_matrix) + if (leaf && NILP (w->buffer)) + /* If the window is deleted, mark just the window itself. */ + VECTOR_MARK (ptr); + else { - mark_glyph_matrix (w->current_matrix); - mark_glyph_matrix (w->desired_matrix); + mark_vectorlike (ptr); + /* Mark glyphs for leaf windows. Marking window + matrices is sufficient because frame matrices + use the same glyph memory. */ + if (leaf && w->current_matrix) + { + mark_glyph_matrix (w->current_matrix); + mark_glyph_matrix (w->desired_matrix); + } } } break; -- cgit v1.2.1 From 0699fc18a5ea00b9a6d64b0e0ebf33b4723beb10 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 6 Sep 2012 11:10:25 +0400 Subject: * alloc.c (mark_object): Revert window marking code since it's unsafe for the Fset_window_configuration. --- src/alloc.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index e90cca637df..aca0a82d1b5 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6019,22 +6019,18 @@ mark_object (Lisp_Object arg) case PVEC_WINDOW: { struct window *w = (struct window *) ptr; - bool leaf = NILP (w->hchild) && NILP (w->vchild); - - if (leaf && NILP (w->buffer)) - /* If the window is deleted, mark just the window itself. */ - VECTOR_MARK (ptr); - else + + /* Even if the window is deleted, we can't mark just the window + itself because set-window-configuration can resurrect it. */ + mark_vectorlike (ptr); + /* Mark glyphs for leaf windows. Marking window + matrices is sufficient because frame matrices + use the same glyph memory. */ + if (NILP (w->hchild) && NILP (w->vchild) + && w->current_matrix) { - mark_vectorlike (ptr); - /* Mark glyphs for leaf windows. Marking window - matrices is sufficient because frame matrices - use the same glyph memory. */ - if (leaf && w->current_matrix) - { - mark_glyph_matrix (w->current_matrix); - mark_glyph_matrix (w->desired_matrix); - } + mark_glyph_matrix (w->current_matrix); + mark_glyph_matrix (w->desired_matrix); } } break; -- cgit v1.2.1 From c752cfa916879f7415990855b52862dd585242ec Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 6 Sep 2012 13:15:44 +0400 Subject: 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/alloc.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index aca0a82d1b5..1a9718bcb25 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; -- cgit v1.2.1 From 2fe282993cf9c84f5be424dc93d03f9705a7edd8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 6 Sep 2012 18:27:44 -0700 Subject: Signal-handler cleanup. Emacs's signal handlers were written in the old 4.2BSD style with sigblock and sigmask and so forth, and this led to some inefficiencies and confusion. Rewrite these to use pthread_sigmask etc. without copying signal sets around. Also, get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and 'signal', and instead use functions that do not attempt to take over the system name space. This patch causes Emacs's text segment to shrink by 0.7% on my platform, Fedora 17 x86-64. * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF): Adjust to syssignal.h changes. (SIGNAL_H_AB): Remove; no longer needed. * src/alloc.c, src/emacsgtkfixed.c, src/nsfns.m, src/widget.c, src/xmenu.c: Do not include or "syssignal.h", as these modules do not use signals. * src/atimer.c, src/callproc.c, src/data.c, src/dispnew.c, src/emacs.c: * src/floatfns.c, src/gtkutil.c, src/keyboard.c, src/process.c, src/sound.c: * src/sysdep.c, src/term.c, src/xterm.c: Do not include , as "syssignal.h" does that for us now. * src/atimer.c (sigmask_atimers): New function. (block_atimers, unblock_atimers): New functions, replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS. All uses replaced. * src/conf_post.h [SIGNAL_H_AHB]: Do not include ; no longer needed here. * src/emacs.c (main): Inspect existing signal handler with sigaction, so that there's no need to block and unblock SIGHUP. * src/sysdep.c (struct save_signal): New member 'action', replacing old member 'handler'. (save_signal_handlers, restore_signal_handlers): Use sigaction instead of 'signal' to save and restore. (get_set_sighandler, set_sighandler) [!WINDOWSNT]: New function. All users of 'signal' modified to use set_sighandler if they're writeonly, and to use sys_signal if they're read+write. (emacs_sigaction_init, forwarded_signal): New functions. (sys_signal): Remove. All uses replaced by calls to sigaction and emacs_sigaction_init, or by direct calls to 'signal'. (sys_sigmask) [!__GNUC__]: Remove; no longer needed. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove; all uses replaced by pthread_sigmask etc. calls. * src/syssignal.h: Include . (emacs_sigaction_init, forwarded_signal): New decls. (SIGMASKTYPE): Remove. All uses replaced by its definiens, sigset_t. (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask. (sigmask, sys_sigmask): Remove; no longer needed. (sigpause): Remove. All uses replaced by its definiens, sigsuspend. (sigblock, sigunblock, sigfree): (sigsetmask) [!defined sigsetmask]: Remove. All uses replaced by pthread_sigmask. (signal): Remove. Its remaining uses (with SIG_DFL and SIG_IGN) no longer need to be replaced, and its typical old uses are now done via emacs_sigaction_init and sigaction. (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls. (sys_sigdel): Remove; unused. (NSIG): Remove a FIXME; the code's fine. Remove an unnecessary ifdef. Fixes: debbugs:12327 --- src/alloc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 1a9718bcb25..bf7c156d321 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -26,8 +26,6 @@ along with GNU Emacs. If not, see . */ #include /* For CHAR_BIT. */ #include -#include - #ifdef HAVE_PTHREAD #include #endif @@ -42,7 +40,6 @@ along with GNU Emacs. If not, see . */ #include "keyboard.h" #include "frame.h" #include "blockinput.h" -#include "syssignal.h" #include "termhooks.h" /* For struct terminal. */ #include #include -- cgit v1.2.1 From b4fa72f2796476e089a57545e0d6dce912b504d3 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 7 Sep 2012 11:05:56 +0400 Subject: * alloc.c (mark_buffer): Revert unsafe marking optimization. (mark_object): Likewise for frame objects. --- src/alloc.c | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index bf7c156d321..aaf2f0846dc 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5842,29 +5842,23 @@ mark_overlay (struct Lisp_Overlay *ptr) static void mark_buffer (struct buffer *buffer) { - if (NILP (BVAR (buffer, name))) - /* If the buffer is killed, mark just the buffer itself. */ - VECTOR_MARK (buffer); - else - { - /* This is handled much like other pseudovectors... */ - mark_vectorlike ((struct Lisp_Vector *) buffer); + /* This is handled much like other pseudovectors... */ + mark_vectorlike ((struct Lisp_Vector *) buffer); - /* ...but there are some buffer-specific things. */ + /* ...but there are some buffer-specific things. */ - MARK_INTERVAL_TREE (buffer_intervals (buffer)); + MARK_INTERVAL_TREE (buffer_intervals (buffer)); - /* For now, we just don't mark the undo_list. It's done later in - a special way just before the sweep phase, and after stripping - some of its elements that are not needed any more. */ + /* For now, we just don't mark the undo_list. It's done later in + a special way just before the sweep phase, and after stripping + some of its elements that are not needed any more. */ - mark_overlay (buffer->overlays_before); - mark_overlay (buffer->overlays_after); + mark_overlay (buffer->overlays_before); + mark_overlay (buffer->overlays_after); - /* If this is an indirect buffer, mark its base buffer. */ - if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) - mark_buffer (buffer->base_buffer); - } + /* If this is an indirect buffer, mark its base buffer. */ + if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) + mark_buffer (buffer->base_buffer); } /* Determine type of generic Lisp_Object and mark it accordingly. */ @@ -6003,26 +5997,14 @@ mark_object (Lisp_Object arg) break; case PVEC_FRAME: - { - struct frame *f = (struct frame *) ptr; - - if (FRAME_LIVE_P (f)) - { - mark_vectorlike (ptr); - mark_face_cache (f->face_cache); - } - else - /* If the frame is deleted, mark just the frame itself. */ - VECTOR_MARK (ptr); - } + mark_vectorlike (ptr); + mark_face_cache (((struct frame *) ptr)->face_cache); break; case PVEC_WINDOW: { struct window *w = (struct window *) ptr; - - /* Even if the window is deleted, we can't mark just the window - itself because set-window-configuration can resurrect it. */ + mark_vectorlike (ptr); /* Mark glyphs for leaf windows. Marking window matrices is sufficient because frame matrices -- cgit v1.2.1 From bc8000ff702f2161253c1f5b54313e32619a2a44 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 7 Sep 2012 10:24:08 +0300 Subject: Fix compilation failure under ENABLE_CHECKING. src/alloc.c [ENABLE_CHECKING]: Include signal.h, since we need SIGABRT. Fixes: debbugs:12327 --- src/alloc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index aaf2f0846dc..33dc68df48e 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -26,6 +26,10 @@ along with GNU Emacs. If not, see . */ #include /* For CHAR_BIT. */ #include +#ifdef ENABLE_CHECKING +#include /* For SIGABRT. */ +#endif + #ifdef HAVE_PTHREAD #include #endif -- cgit v1.2.1