emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/ralloc.c


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/ralloc.c
Date: Fri, 04 Apr 2003 01:24:00 -0500

Index: emacs/src/ralloc.c
diff -c emacs/src/ralloc.c:1.55 emacs/src/ralloc.c:1.56
*** emacs/src/ralloc.c:1.55     Mon Feb 19 07:19:40 2001
--- emacs/src/ralloc.c  Tue Feb  4 09:03:13 2003
***************
*** 1,4 ****
! /* Block-relocating memory allocator. 
     Copyright (C) 1993, 1995, 2000 Free Software Foundation, Inc.
  
  This file is part of GNU Emacs.
--- 1,4 ----
! /* Block-relocating memory allocator.
     Copyright (C) 1993, 1995, 2000 Free Software Foundation, Inc.
  
  This file is part of GNU Emacs.
***************
*** 42,48 ****
  extern void safe_bcopy ();
  
  #ifdef DOUG_LEA_MALLOC
! #define M_TOP_PAD           -2 
  extern int mallopt ();
  #else /* not DOUG_LEA_MALLOC */
  #ifndef SYSTEM_MALLOC
--- 42,48 ----
  extern void safe_bcopy ();
  
  #ifdef DOUG_LEA_MALLOC
! #define M_TOP_PAD           -2
  extern int mallopt ();
  #else /* not DOUG_LEA_MALLOC */
  #ifndef SYSTEM_MALLOC
***************
*** 98,104 ****
  /* This is the size of a page.  We round memory requests to this boundary.  */
  static int page_size;
  
! /* Whenever we get memory from the system, get this many extra bytes.  This 
     must be a multiple of page_size.  */
  static int extra_bytes;
  
--- 98,104 ----
  /* This is the size of a page.  We round memory requests to this boundary.  */
  static int page_size;
  
! /* Whenever we get memory from the system, get this many extra bytes.  This
     must be a multiple of page_size.  */
  static int extra_bytes;
  
***************
*** 141,147 ****
     We try to make just one heap and make it larger as necessary.
     But sometimes we can't do that, because we can't get contiguous
     space to add onto the heap.  When that happens, we start a new heap.  */
!    
  typedef struct heap
  {
    struct heap *next;
--- 141,147 ----
     We try to make just one heap and make it larger as necessary.
     But sometimes we can't do that, because we can't get contiguous
     space to add onto the heap.  When that happens, we start a new heap.  */
! 
  typedef struct heap
  {
    struct heap *next;
***************
*** 174,180 ****
  /* These structures are allocated in the malloc arena.
     The linked list is kept in order of increasing '.data' members.
     The data blocks abut each other; if b->next is non-nil, then
!    b->data + b->size == b->next->data.  
  
     An element with variable==NIL denotes a freed block, which has not yet
     been collected.  They may only appear while r_alloc_freeze > 0, and will be
--- 174,180 ----
  /* These structures are allocated in the malloc arena.
     The linked list is kept in order of increasing '.data' members.
     The data blocks abut each other; if b->next is non-nil, then
!    b->data + b->size == b->next->data.
  
     An element with variable==NIL denotes a freed block, which has not yet
     been collected.  They may only appear while r_alloc_freeze > 0, and will be
***************
*** 467,474 ****
  /* Calculate new locations of blocs in the list beginning with BLOC,
     relocating it to start at ADDRESS, in heap HEAP.  If enough space is
     not presently available in our reserve, call obtain for
!    more space. 
!    
     Store the new location of each bloc in its new_data field.
     Do not touch the contents of blocs or break_value.  */
  
--- 467,474 ----
  /* Calculate new locations of blocs in the list beginning with BLOC,
     relocating it to start at ADDRESS, in heap HEAP.  If enough space is
     not presently available in our reserve, call obtain for
!    more space.
! 
     Store the new location of each bloc in its new_data field.
     Do not touch the contents of blocs or break_value.  */
  
***************
*** 481,487 ****
    register bloc_ptr b = bloc;
  
    /* No need to ever call this if arena is frozen, bug somewhere!  */
!   if (r_alloc_freeze_level) 
      abort();
  
    while (b)
--- 481,487 ----
    register bloc_ptr b = bloc;
  
    /* No need to ever call this if arena is frozen, bug somewhere!  */
!   if (r_alloc_freeze_level)
      abort();
  
    while (b)
***************
*** 506,512 ****
          /* Add up the size of all the following blocs.  */
          while (tb != NIL_BLOC)
            {
!             if (tb->variable) 
                s += tb->size;
  
              tb = tb->next;
--- 506,512 ----
          /* Add up the size of all the following blocs.  */
          while (tb != NIL_BLOC)
            {
!             if (tb->variable)
                s += tb->size;
  
              tb = tb->next;
***************
*** 523,529 ****
        /* Record the new address of this bloc
         and update where the next bloc can start.  */
        b->new_data = address;
!       if (b->variable) 
        address = (char *) address + b->size;
        b = b->next;
      }
--- 523,529 ----
        /* Record the new address of this bloc
         and update where the next bloc can start.  */
        b->new_data = address;
!       if (b->variable)
        address = (char *) address + b->size;
        b = b->next;
      }
***************
*** 639,645 ****
    SIZE old_size;
  
    /* No need to ever call this if arena is frozen, bug somewhere!  */
!   if (r_alloc_freeze_level) 
      abort();
  
    if (bloc == NIL_BLOC || size == bloc->size)
--- 639,645 ----
    SIZE old_size;
  
    /* No need to ever call this if arena is frozen, bug somewhere!  */
!   if (r_alloc_freeze_level)
      abort();
  
    if (bloc == NIL_BLOC || size == bloc->size)
***************
*** 681,688 ****
            {
              b->size = 0;
              b->data = b->new_data;
!             } 
!         else 
            {
              safe_bcopy (b->data, b->new_data, b->size);
              *b->variable = b->data = b->new_data;
--- 681,688 ----
            {
              b->size = 0;
              b->data = b->new_data;
!             }
!         else
            {
              safe_bcopy (b->data, b->new_data, b->size);
              *b->variable = b->data = b->new_data;
***************
*** 708,715 ****
            {
              b->size = 0;
              b->data = b->new_data;
!             } 
!         else 
            {
              safe_bcopy (b->data, b->new_data, b->size);
              *b->variable = b->data = b->new_data;
--- 708,715 ----
            {
              b->size = 0;
              b->data = b->new_data;
!             }
!         else
            {
              safe_bcopy (b->data, b->new_data, b->size);
              *b->variable = b->data = b->new_data;
***************
*** 738,744 ****
        bloc->variable = (POINTER *) NIL;
        return;
      }
!   
    resize_bloc (bloc, 0);
  
    if (bloc == first_bloc && bloc == last_bloc)
--- 738,744 ----
        bloc->variable = (POINTER *) NIL;
        return;
      }
! 
    resize_bloc (bloc, 0);
  
    if (bloc == first_bloc && bloc == last_bloc)
***************
*** 794,800 ****
     __morecore hook values - in particular, __default_morecore in the
     GNU malloc package.  */
  
! POINTER 
  r_alloc_sbrk (size)
       long size;
  {
--- 794,800 ----
     __morecore hook values - in particular, __default_morecore in the
     GNU malloc package.  */
  
! POINTER
  r_alloc_sbrk (size)
       long size;
  {
***************
*** 850,856 ****
        if (first_heap->bloc_start < new_bloc_start)
        {
          /* This is no clean solution - no idea how to do it better.  */
!         if (r_alloc_freeze_level) 
            return NIL;
  
          /* There is a bug here: if the above obtain call succeeded, but the
--- 850,856 ----
        if (first_heap->bloc_start < new_bloc_start)
        {
          /* This is no clean solution - no idea how to do it better.  */
!         if (r_alloc_freeze_level)
            return NIL;
  
          /* There is a bug here: if the above obtain call succeeded, but the
***************
*** 1018,1024 ****
  
    if (!*ptr)
      return r_alloc (ptr, size);
!   if (!size) 
      {
        r_alloc_free (ptr);
        return r_alloc (ptr, 0);
--- 1018,1024 ----
  
    if (!*ptr)
      return r_alloc (ptr, size);
!   if (!size)
      {
        r_alloc_free (ptr);
        return r_alloc (ptr, 0);
***************
*** 1028,1039 ****
    if (bloc == NIL_BLOC)
      abort ();
  
!   if (size < bloc->size) 
      {
        /* Wouldn't it be useful to actually resize the bloc here?  */
        /* I think so too, but not if it's too expensive...  */
!       if ((bloc->size - MEM_ROUNDUP (size) >= page_size) 
!           && r_alloc_freeze_level == 0) 
        {
          resize_bloc (bloc, MEM_ROUNDUP (size));
          /* Never mind if this fails, just do nothing...  */
--- 1028,1039 ----
    if (bloc == NIL_BLOC)
      abort ();
  
!   if (size < bloc->size)
      {
        /* Wouldn't it be useful to actually resize the bloc here?  */
        /* I think so too, but not if it's too expensive...  */
!       if ((bloc->size - MEM_ROUNDUP (size) >= page_size)
!           && r_alloc_freeze_level == 0)
        {
          resize_bloc (bloc, MEM_ROUNDUP (size));
          /* Never mind if this fails, just do nothing...  */
***************
*** 1055,1061 ****
            else
            return NIL;
        }
!       else 
        {
          if (! resize_bloc (bloc, MEM_ROUNDUP (size)))
            return NIL;
--- 1055,1061 ----
            else
            return NIL;
        }
!       else
        {
          if (! resize_bloc (bloc, MEM_ROUNDUP (size)))
            return NIL;
***************
*** 1091,1112 ****
  r_alloc_thaw ()
  {
  
!   if (! r_alloc_initialized) 
      r_alloc_init ();
  
    if (--r_alloc_freeze_level < 0)
      abort ();
  
!   /* This frees all unused blocs.  It is not too inefficient, as the resize 
!      and bcopy is done only once.  Afterwards, all unreferenced blocs are 
       already shrunk to zero size.  */
!   if (!r_alloc_freeze_level) 
      {
        bloc_ptr *b = &first_bloc;
!       while (*b) 
!       if (!(*b)->variable) 
!         free_bloc (*b); 
!       else 
          b = &(*b)->next;
      }
  }
--- 1091,1112 ----
  r_alloc_thaw ()
  {
  
!   if (! r_alloc_initialized)
      r_alloc_init ();
  
    if (--r_alloc_freeze_level < 0)
      abort ();
  
!   /* This frees all unused blocs.  It is not too inefficient, as the resize
!      and bcopy is done only once.  Afterwards, all unreferenced blocs are
       already shrunk to zero size.  */
!   if (!r_alloc_freeze_level)
      {
        bloc_ptr *b = &first_bloc;
!       while (*b)
!       if (!(*b)->variable)
!         free_bloc (*b);
!       else
          b = &(*b)->next;
      }
  }
***************
*** 1238,1244 ****
    if (r_alloc_initialized)
      return;
    r_alloc_initialized = 1;
!   
    page_size = PAGE;
  #ifndef SYSTEM_MALLOC
    real_morecore = __morecore;
--- 1238,1244 ----
    if (r_alloc_initialized)
      return;
    r_alloc_initialized = 1;
! 
    page_size = PAGE;
  #ifndef SYSTEM_MALLOC
    real_morecore = __morecore;
***************
*** 1283,1288 ****
         (char *) first_heap->end - (char *) first_heap->start);
    virtual_break_value = break_value = first_heap->bloc_start = 
first_heap->end;
  #endif
!   
    use_relocatable_buffers = 1;
  }
--- 1283,1288 ----
         (char *) first_heap->end - (char *) first_heap->start);
    virtual_break_value = break_value = first_heap->bloc_start = 
first_heap->end;
  #endif
! 
    use_relocatable_buffers = 1;
  }




reply via email to

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