emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/alloc.c [emacs-unicode-2]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/alloc.c [emacs-unicode-2]
Date: Mon, 28 Jun 2004 03:56:37 -0400

Index: emacs/src/alloc.c
diff -c emacs/src/alloc.c:1.318.2.3 emacs/src/alloc.c:1.318.2.4
*** emacs/src/alloc.c:1.318.2.3 Fri Apr 16 12:50:44 2004
--- emacs/src/alloc.c   Mon Jun 28 07:29:17 2004
***************
*** 155,160 ****
--- 155,161 ----
  
  EMACS_INT undo_limit;
  EMACS_INT undo_strong_limit;
+ EMACS_INT undo_outer_limit;
  
  /* Number of live and free conses etc.  */
  
***************
*** 256,261 ****
--- 257,263 ----
  
  static void mark_buffer P_ ((Lisp_Object));
  extern void mark_kboards P_ ((void));
+ extern void mark_backtrace P_ ((void));
  static void gc_sweep P_ ((void));
  static void mark_glyph_matrix P_ ((struct glyph_matrix *));
  static void mark_face_cache P_ ((struct face_cache *));
***************
*** 753,769 ****
  #ifdef HAVE_POSIX_MEMALIGN
        {
        int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
!       abase = err ? (base = NULL) : base;
        }
  #else
        base = malloc (ABLOCKS_BYTES);
        abase = ALIGN (base, BLOCK_ALIGN);
        if (base == 0)
        {
          UNBLOCK_INPUT;
          memory_full ();
        }
- #endif
  
        aligned = (base == abase);
        if (!aligned)
--- 755,774 ----
  #ifdef HAVE_POSIX_MEMALIGN
        {
        int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
!       if (err)
!         base = NULL;
!       abase = base;
        }
  #else
        base = malloc (ABLOCKS_BYTES);
        abase = ALIGN (base, BLOCK_ALIGN);
+ #endif
+ 
        if (base == 0)
        {
          UNBLOCK_INPUT;
          memory_full ();
        }
  
        aligned = (base == abase);
        if (!aligned)
***************
*** 844,850 ****
    free_ablock = ablock;
    /* Update busy count.  */
    ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY 
(abase));
!   
    if (2 > (long) ABLOCKS_BUSY (abase))
      { /* All the blocks are free.  */
        int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
--- 849,855 ----
    free_ablock = ablock;
    /* Update busy count.  */
    ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY 
(abase));
! 
    if (2 > (long) ABLOCKS_BUSY (abase))
      { /* All the blocks are free.  */
        int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
***************
*** 1893,1900 ****
  
  
  DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
!        doc: /* Return a newly created string of length LENGTH, with each 
element being INIT.
! Both LENGTH and INIT must be numbers.  */)
       (length, init)
       Lisp_Object length, init;
  {
--- 1898,1906 ----
  
  
  DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
!        doc: /* Return a newly created string of length LENGTH, with INIT in 
each element.
! LENGTH must be an integer.
! INIT must be an integer that represents a character.  */)
       (length, init)
       Lisp_Object length, init;
  {
***************
*** 1949,1958 ****
  
    CHECK_NATNUM (length);
  
!   bits_per_value = sizeof (EMACS_INT) * BITS_PER_CHAR;
  
    length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value;
!   length_in_chars = ((XFASTINT (length) + BITS_PER_CHAR - 1) / BITS_PER_CHAR);
  
    /* We must allocate one more elements than LENGTH_IN_ELTS for the
       slot `size' of the struct Lisp_Bool_Vector.  */
--- 1955,1965 ----
  
    CHECK_NATNUM (length);
  
!   bits_per_value = sizeof (EMACS_INT) * BOOL_VECTOR_BITS_PER_CHAR;
  
    length_in_elts = (XFASTINT (length) + bits_per_value - 1) / bits_per_value;
!   length_in_chars = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
!                    / BOOL_VECTOR_BITS_PER_CHAR);
  
    /* We must allocate one more elements than LENGTH_IN_ELTS for the
       slot `size' of the struct Lisp_Bool_Vector.  */
***************
*** 1969,1977 ****
      p->data[i] = real_init;
  
    /* Clear the extraneous bits in the last byte.  */
!   if (XINT (length) != length_in_chars * BITS_PER_CHAR)
      XBOOL_VECTOR (val)->data[length_in_chars - 1]
!       &= (1 << (XINT (length) % BITS_PER_CHAR)) - 1;
  
    return val;
  }
--- 1976,1984 ----
      p->data[i] = real_init;
  
    /* Clear the extraneous bits in the last byte.  */
!   if (XINT (length) != length_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
      XBOOL_VECTOR (val)->data[length_in_chars - 1]
!       &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
  
    return val;
  }
***************
*** 2333,2339 ****
    cons_free_list = ptr;
  }
  
- 
  DEFUN ("cons", Fcons, Scons, 2, 2, 0,
         doc: /* Create a new cons, give it CAR and CDR as components, and 
return it.  */)
       (car, cdr)
--- 2340,2345 ----
***************
*** 4233,4250 ****
      struct catchtag *next;
  };
  
- struct backtrace
- {
-   struct backtrace *next;
-   Lisp_Object *function;
-   Lisp_Object *args;  /* Points to vector of args.  */
-   int nargs;          /* Length of vector.  */
-   /* If nargs is UNEVALLED, args points to slot holding list of
-      unevalled args.  */
-   char evalargs;
- };
- 
- 
  
  /***********************************************************************
                          Protection from GC
--- 4239,4244 ----
***************
*** 4279,4285 ****
    register struct specbinding *bind;
    struct catchtag *catch;
    struct handler *handler;
-   register struct backtrace *backlist;
    char stack_top_variable;
    register int i;
    int message_p;
--- 4273,4278 ----
***************
*** 4348,4354 ****
        if (! EQ (nextb->undo_list, Qt))
          nextb->undo_list
            = truncate_undo_list (nextb->undo_list, undo_limit,
!                                 undo_strong_limit);
  
        /* Shrink buffer gaps, but skip indirect and dead buffers.  */
        if (nextb->base_buffer == 0 && !NILP (nextb->name))
--- 4341,4347 ----
        if (! EQ (nextb->undo_list, Qt))
          nextb->undo_list
            = truncate_undo_list (nextb->undo_list, undo_limit,
!                                 undo_strong_limit, undo_outer_limit);
  
        /* Shrink buffer gaps, but skip indirect and dead buffers.  */
        if (nextb->base_buffer == 0 && !NILP (nextb->name))
***************
*** 4408,4427 ****
        mark_object (handler->handler);
        mark_object (handler->var);
      }
!   for (backlist = backtrace_list; backlist; backlist = backlist->next)
!     {
!       mark_object (*backlist->function);
! 
!       if (backlist->nargs == UNEVALLED || backlist->nargs == MANY)
!       i = 0;
!       else
!       i = backlist->nargs - 1;
!       for (; i >= 0; i--)
!       mark_object (backlist->args[i]);
!     }
    mark_kboards ();
  
!   /* Look thru every buffer's undo list
       for elements that update markers that were not marked,
       and delete them.  */
    {
--- 4401,4423 ----
        mark_object (handler->handler);
        mark_object (handler->var);
      }
!   mark_backtrace ();
    mark_kboards ();
  
! #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
!   mark_stack ();
! #endif
! 
! #ifdef USE_GTK
!   {
!     extern void xg_mark_data ();
!     xg_mark_data ();
!   }
! #endif
! 
!   /* Everything is now marked, except for the things that require special
!      finalization, i.e. the undo_list.
!      Look thru every buffer's undo list
       for elements that update markers that were not marked,
       and delete them.  */
    {
***************
*** 4459,4480 ****
                  }
              }
          }
  
        nextb = nextb->next;
        }
    }
  
- #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
-   mark_stack ();
- #endif
- 
- #ifdef USE_GTK
-   {
-     extern void xg_mark_data ();
-     xg_mark_data ();
-   }
- #endif
- 
    gc_sweep ();
  
    /* Clear the mark bits that we set in certain root slots.  */
--- 4455,4468 ----
                  }
              }
          }
+       /* Now that we have stripped the elements that need not be in the
+          undo_list any more, we can finally mark the list.  */
+       mark_object (nextb->undo_list);
  
        nextb = nextb->next;
        }
    }
  
    gc_sweep ();
  
    /* Clear the mark bits that we set in certain root slots.  */
***************
*** 5043,5083 ****
  
    MARK_INTERVAL_TREE (BUF_INTERVALS (buffer));
  
!   if (CONSP (buffer->undo_list))
!     {
!       Lisp_Object tail;
!       tail = buffer->undo_list;
! 
!       /* We mark the undo list specially because
!        its pointers to markers should be weak.  */
! 
!       while (CONSP (tail))
!       {
!         register struct Lisp_Cons *ptr = XCONS (tail);
! 
!         if (CONS_MARKED_P (ptr))
!           break;
!         CONS_MARK (ptr);
!         if (GC_CONSP (ptr->car)
!             && !CONS_MARKED_P (XCONS (ptr->car))
!             && GC_MARKERP (XCAR (ptr->car)))
!           {
!             CONS_MARK (XCONS (ptr->car));
!             mark_object (XCDR (ptr->car));
!           }
!         else
!           mark_object (ptr->car);
! 
!         if (CONSP (ptr->cdr))
!           tail = ptr->cdr;
!         else
!           break;
!       }
! 
!       mark_object (XCDR (tail));
!     }
!   else
!     mark_object (buffer->undo_list);
  
    if (buffer->overlays_before)
      {
--- 5031,5039 ----
  
    MARK_INTERVAL_TREE (BUF_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.  */
  
    if (buffer->overlays_before)
      {
***************
*** 5671,5682 ****
  
    DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
              doc: /* Don't keep more than this much size of undo information.
! A command which pushes past this size is itself forgotten.
! This limit is applied when garbage collection happens.
  The size is counted as the number of bytes occupied,
  which includes both saved text and other data.  */);
    undo_strong_limit = 30000;
  
    DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
               doc: /* Non-nil means display messages at start and end of 
garbage collection.  */);
    garbage_collection_messages = 0;
--- 5627,5646 ----
  
    DEFVAR_INT ("undo-strong-limit", &undo_strong_limit,
              doc: /* Don't keep more than this much size of undo information.
! A previous command which pushes the undo list past this size
! is entirely forgotten when GC happens.
  The size is counted as the number of bytes occupied,
  which includes both saved text and other data.  */);
    undo_strong_limit = 30000;
  
+   DEFVAR_INT ("undo-outer-limit", &undo_outer_limit,
+             doc: /* Don't keep more than this much size of undo information.
+ If the current command has produced more than this much undo information,
+ GC discards it.  This is a last-ditch limit to prevent memory overflow.
+ The size is counted as the number of bytes occupied,
+ which includes both saved text and other data.  */);
+   undo_outer_limit = 300000;
+ 
    DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages,
               doc: /* Non-nil means display messages at start and end of 
garbage collection.  */);
    garbage_collection_messages = 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]