* frame.c (make_initial_frame):
[bpt/emacs.git] / src / alloc.c
index 031cb99..b009157 100644 (file)
@@ -1,6 +1,6 @@
 /* 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, 2008
+      2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
       Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <stdio.h>
 #include <limits.h>            /* For CHAR_BIT.  */
+#include <setjmp.h>
 
 #ifdef STDC_HEADERS
 #include <stddef.h>            /* For offsetof, used by PSEUDOVECSIZE. */
@@ -30,8 +31,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #undef INLINE
 #endif
 
-/* Note that this declares bzero on OSF/1.  How dumb.  */
-
 #include <signal.h>
 
 #ifdef HAVE_GTK_AND_PTHREAD
@@ -499,7 +498,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.  */
@@ -797,6 +796,8 @@ void
 xfree (block)
      POINTER_TYPE *block;
 {
+  if (!block)
+    return;
   MALLOC_BLOCK_INPUT;
   free (block);
   MALLOC_UNBLOCK_INPUT;
@@ -1539,7 +1540,7 @@ mark_interval_tree (tree)
   } while (0)
 
 \f
-/* 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
@@ -2641,7 +2642,7 @@ make_float (float_value)
 
   MALLOC_UNBLOCK_INPUT;
 
-  XFLOAT_DATA (val) = float_value;
+  XFLOAT_INIT (val, float_value);
   eassert (!FLOAT_MARKED_P (XFLOAT (val)));
   consing_since_gc += sizeof (struct Lisp_Float);
   floats_consed++;
@@ -4148,8 +4149,7 @@ mark_maybe_object (obj)
          mark_p = (live_misc_p (m, po) && !XMISCANY (obj)->gcmarkbit);
          break;
 
-       case Lisp_Int:
-       case Lisp_Type_Limit:
+       default:
          break;
        }
 
@@ -4485,8 +4485,13 @@ 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__
+#if defined (__sparc64__) && defined (__FreeBSD__)
+  /* FreeBSD does not have a ta 3 handler.  */
+  asm ("flushw");
+#else
   asm ("ta 3");
+#endif
 #endif
 
   /* Save registers that we need to see on the stack.  We need to see
@@ -4813,6 +4818,24 @@ make_pure_string (data, nchars, nbytes, multibyte)
   return string;
 }
 
+/* Return a string a string allocated in pure space.  Do not allocate
+   the string data, just point to DATA.  */
+
+Lisp_Object
+make_pure_c_string (const char *data)
+{
+  Lisp_Object string;
+  struct Lisp_String *s;
+  int nchars = strlen (data);
+
+  s = (struct Lisp_String *) pure_alloc (sizeof *s, Lisp_String);
+  s->size = nchars;
+  s->size_byte = -1;
+  s->data = (unsigned char *) data;
+  s->intervals = NULL_INTERVAL;
+  XSETSTRING (string, s);
+  return string;
+}
 
 /* Return a cons allocated from pure space.  Give it pure copies
    of CAR as car and CDR as cdr.  */
@@ -4843,7 +4866,7 @@ make_pure_float (num)
 
   p = (struct Lisp_Float *) pure_alloc (sizeof *p, Lisp_Float);
   XSETFLOAT (new, p);
-  XFLOAT_DATA (new) = num;
+  XFLOAT_INIT (new, num);
   return new;
 }
 
@@ -4932,13 +4955,6 @@ staticpro (varaddress)
     abort ();
 }
 
-struct catchtag
-{
-    Lisp_Object tag;
-    Lisp_Object val;
-    struct catchtag *next;
-};
-
 \f
 /***********************************************************************
                          Protection from GC
@@ -5364,6 +5380,34 @@ mark_vectorlike (ptr)
   return 1;
 }
 
+/* Like mark_vectorlike but optimized for char-tables (and
+   sub-char-tables) assuming that the contents are mostly integers or
+   symbols.  */
+
+static void
+mark_char_table (ptr)
+     struct Lisp_Vector *ptr;
+{
+  register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK;
+  register int i;
+
+  VECTOR_MARK (ptr);
+  for (i = 0; i < size; i++)
+    {
+      Lisp_Object val = ptr->contents[i];
+
+      if (INTEGERP (val) || SYMBOLP (val) && XSYMBOL (val)->gcmarkbit)
+       continue;
+      if (SUB_CHAR_TABLE_P (val))
+       {
+         if (! VECTOR_MARKED_P (XVECTOR (val)))
+           mark_char_table (XVECTOR (val));
+       }
+      else
+       mark_object (val);
+    }
+}
+
 void
 mark_object (arg)
      Lisp_Object arg;
@@ -5526,6 +5570,11 @@ mark_object (arg)
                VECTOR_MARK (XVECTOR (h->key_and_value));
            }
        }
+      else if (CHAR_TABLE_P (obj))
+       {
+         if (! VECTOR_MARKED_P (XVECTOR (obj)))
+           mark_char_table (XVECTOR (obj));
+       }
       else
        mark_vectorlike (XVECTOR (obj));
       break;
@@ -5663,7 +5712,7 @@ mark_object (arg)
       FLOAT_MARK (XFLOAT (obj));
       break;
 
-    case Lisp_Int:
+    case_Lisp_Int:
       break;
 
     default:
@@ -5749,7 +5798,7 @@ survives_gc_p (obj)
 
   switch (XTYPE (obj))
     {
-    case Lisp_Int:
+    case_Lisp_Int:
       survives_p = 1;
       break;
 
@@ -6344,7 +6393,7 @@ This means that certain objects should be allocated in shared (pure) space.  */)
   DEFVAR_LISP ("post-gc-hook", &Vpost_gc_hook,
               doc: /* Hook run after garbage collection has finished.  */);
   Vpost_gc_hook = Qnil;
-  Qpost_gc_hook = intern ("post-gc-hook");
+  Qpost_gc_hook = intern_c_string ("post-gc-hook");
   staticpro (&Qpost_gc_hook);
 
   DEFVAR_LISP ("memory-signal-data", &Vmemory_signal_data,
@@ -6352,18 +6401,18 @@ This means that certain objects should be allocated in shared (pure) space.  */)
   /* We build this in advance because if we wait until we need it, we might
      not be able to allocate the memory to hold it.  */
   Vmemory_signal_data
-    = list2 (Qerror,
-            build_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"));
+    = pure_cons (Qerror,
+                pure_cons (make_pure_c_string ("Memory exhausted--use M-x save-some-buffers then exit and restart Emacs"), Qnil));
 
   DEFVAR_LISP ("memory-full", &Vmemory_full,
               doc: /* Non-nil means Emacs cannot get much more Lisp memory.  */);
   Vmemory_full = Qnil;
 
   staticpro (&Qgc_cons_threshold);
-  Qgc_cons_threshold = intern ("gc-cons-threshold");
+  Qgc_cons_threshold = intern_c_string ("gc-cons-threshold");
 
   staticpro (&Qchar_table_extra_slots);
-  Qchar_table_extra_slots = intern ("char-table-extra-slots");
+  Qchar_table_extra_slots = intern_c_string ("char-table-extra-slots");
 
   DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed,
               doc: /* Accumulated time elapsed in garbage collections.