X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/1ccaa71a47a4e7a0c3fafa2f91182421b3314f31..b7e1d896e0651d34fda0dca3ebe1874b3bfddc01:/src/alloc.c diff --git a/src/alloc.c b/src/alloc.c index 5e3c38943f..9fe78e8806 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,13 +1,14 @@ /* Storage allocation and gc for GNU Emacs Lisp interpreter. Copyright (C) 1985, 1986, 1988, 1993, 1994, 1995, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 + Free Software Foundation, Inc. This file is part of GNU Emacs. -GNU Emacs is free software; you can redistribute it and/or modify +GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ +along with GNU Emacs. If not, see . */ #include #include @@ -352,8 +351,6 @@ static void mark_face_cache P_ ((struct face_cache *)); #ifdef HAVE_WINDOW_SYSTEM extern void mark_fringe_data P_ ((void)); -static void mark_image P_ ((struct image *)); -static void mark_image_cache P_ ((struct frame *)); #endif /* HAVE_WINDOW_SYSTEM */ static struct Lisp_String *allocate_string P_ ((void)); @@ -502,7 +499,7 @@ struct gcpro *gcprolist; /* Addresses of staticpro'd variables. Initialize it to a nonzero value; otherwise some compilers put it into BSS. */ -#define NSTATICS 0x600 +#define NSTATICS 0x640 static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; /* Index of next unused slot in staticvec. */ @@ -800,6 +797,8 @@ void xfree (block) POINTER_TYPE *block; { + if (!block) + return; MALLOC_BLOCK_INPUT; free (block); MALLOC_UNBLOCK_INPUT; @@ -1367,6 +1366,7 @@ void uninterrupt_malloc () { #ifdef HAVE_GTK_AND_PTHREAD +#ifdef DOUG_LEA_MALLOC pthread_mutexattr_t attr; /* GLIBC has a faster way to do this, but lets keep it portable. @@ -1374,6 +1374,11 @@ uninterrupt_malloc () pthread_mutexattr_init (&attr); pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init (&alloc_mutex, &attr); +#else /* !DOUG_LEA_MALLOC */ + /* Some systems such as Solaris 2.6 doesn't have a recursive mutex, + and the bundled gmalloc.c doesn't require it. */ + pthread_mutex_init (&alloc_mutex, NULL); +#endif /* !DOUG_LEA_MALLOC */ #endif /* HAVE_GTK_AND_PTHREAD */ if (__free_hook != emacs_blocked_free) @@ -1536,7 +1541,7 @@ mark_interval_tree (tree) } while (0) -/* Number support. If NO_UNION_TYPE isn't in effect, we +/* Number support. If USE_LISP_UNION_TYPE is in effect, we can't create number objects in macros. */ #ifndef make_number Lisp_Object @@ -1927,11 +1932,7 @@ allocate_string () consing_since_gc += sizeof *s; #ifdef GC_CHECK_STRING_BYTES - if (!noninteractive -#ifdef MAC_OS8 - && current_sblock -#endif - ) + if (!noninteractive) { if (++check_string_bytes_count == 200) { @@ -2967,7 +2968,7 @@ allocate_vector (nslots) /* Allocate other vector-like structures. */ -static struct Lisp_Vector * +struct Lisp_Vector * allocate_pseudovector (memlen, lisplen, tag) int memlen, lisplen; EMACS_INT tag; @@ -2983,10 +2984,6 @@ allocate_pseudovector (memlen, lisplen, tag) XSETPVECTYPE (v, tag); /* Add the appropriate tag. */ return v; } -#define ALLOCATE_PSEUDOVECTOR(typ,field,tag) \ - ((typ*) \ - allocate_pseudovector \ - (VECSIZE (typ), PSEUDOVECSIZE (typ, field), tag)) struct Lisp_Hash_Table * allocate_hash_table (void) @@ -3033,22 +3030,6 @@ allocate_process () } -/* Only used for PVEC_WINDOW_CONFIGURATION. */ -struct Lisp_Vector * -allocate_other_vector (len) - EMACS_INT len; -{ - struct Lisp_Vector *v = allocate_vectorlike (len); - EMACS_INT i; - - for (i = 0; i < len; ++i) - v->contents[i] = Qnil; - v->size = len; - - return v; -} - - DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, doc: /* Return a newly created vector of length LENGTH, with each element being INIT. See also the function `vector'. */) @@ -4506,7 +4487,7 @@ mark_stack () /* Fixme: Code in the Boehm GC suggests flushing (with `flushrs') is needed on ia64 too. See mach_dep.c, where it also says inline assembler doesn't work with relevant proprietary compilers. */ -#ifdef sparc +#ifdef __sparc__ asm ("ta 3"); #endif @@ -5347,34 +5328,6 @@ mark_face_cache (c) } -#ifdef HAVE_WINDOW_SYSTEM - -/* Mark Lisp objects in image IMG. */ - -static void -mark_image (img) - struct image *img; -{ - mark_object (img->spec); - - if (!NILP (img->data.lisp_val)) - mark_object (img->data.lisp_val); -} - - -/* Mark Lisp objects in image cache of frame F. It's done this way so - that we don't have to include xterm.h here. */ - -static void -mark_image_cache (f) - struct frame *f; -{ - forall_images_in_image_cache (f, mark_image); -} - -#endif /* HAVE_X_WINDOWS */ - - /* Mark reference to a Lisp_Object. If the object referred to has not been seen yet, recursively mark @@ -5543,12 +5496,7 @@ mark_object (arg) { register struct frame *ptr = XFRAME (obj); if (mark_vectorlike (XVECTOR (obj))) - { - mark_face_cache (ptr->face_cache); -#ifdef HAVE_WINDOW_SYSTEM - mark_image_cache (ptr); -#endif /* HAVE_WINDOW_SYSTEM */ - } + mark_face_cache (ptr->face_cache); } else if (WINDOWP (obj)) { @@ -5758,6 +5706,8 @@ mark_buffer (buf) mark_object (tmp); } + /* buffer-local Lisp variables start at `undo_list', + tho only the ones from `name' on are GC'd normally. */ for (ptr = &buffer->name; (char *)ptr < (char *)buffer + sizeof (struct buffer); ptr++) @@ -5781,6 +5731,9 @@ mark_terminals (void) for (t = terminal_list; t; t = t->next_terminal) { eassert (t->name != NULL); +#ifdef HAVE_WINDOW_SYSTEM + mark_image_cache (t->image_cache); +#endif /* HAVE_WINDOW_SYSTEM */ mark_vectorlike ((struct Lisp_Vector *)t); } } @@ -6296,6 +6249,7 @@ init_alloc_once () init_marker (); init_float (); init_intervals (); + init_weak_hash_tables (); #ifdef REL_ALLOC malloc_hysteresis = 32;