This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Increase PAGESIZE in mips-tfile.c (take 2)


On Fri, 23 May 2003, Mike Stump wrote:
> On Thursday, May 22, 2003, at 09:21 PM, Roger Sayle wrote:
> > The following patch increases the PAGE_SIZE used for memory allocation
> > in mips-tfile.c from 4K to 8K.
>
> Please, no, 8K is just as bad as 4K.  Please change to 64K.

Ok.

When I said in my last e-mail that the value of PAGE_SIZE was probably
only limited by unsigned long, this is true for its use in the shash_t
structure that I previously described.  Unfortunately, its also used in
mips-tfile.c by the varray_t structure below:

/* Virtual array header.  */
typedef struct varray {
  vlinks_t      *first;                 /* first page link */
  vlinks_t      *last;                  /* last page link */
  unsigned long  num_allocated;         /* # objects allocated */
  unsigned short object_size;           /* size in bytes of each object */
  unsigned short objects_per_page;      /* # objects that can fit on a page */
  unsigned short objects_last_page;     /* # objects allocated on last page */
} varray_t;

#ifndef MALLOC_CHECK
#define OBJECTS_PER_PAGE(type) (PAGE_SIZE / sizeof (type))
#else
#define OBJECTS_PER_PAGE(type) ((sizeof (type) > 1) ? 1 : PAGE_SIZE)
#endif

Notice that the "objects_per_page" field may potentially be assigned
the value PAGE_SIZE.  Unfortunately, with a PAGE_SIZE of 65536 (64K),
we overflow the "unsigned short" field, and bad things happen.


However, we can increase PAGE_SIZE from 4096 (4K) to 32768 (32K) without
any problems.  The following patch has been bootstrapped and regression
tested on alphaev67-dec-osf5.1 with a full "make bootstrap", all
languages except Ada and treelang, and regression checked with a
top-level "make -k check" with no new failures.

Is this 32K patch or the earlier 8K patch OK for mainline?


2003-05-24  Roger Sayle  <roger@eyesopen.com>

	* mips-tfile.c (PAGE_SIZE): Increase page size to 32K.

Index: mips-tfile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/mips-tfile.c,v
retrieving revision 1.52
diff -c -3 -p -r1.52 mips-tfile.c
*** mips-tfile.c	17 May 2003 22:21:32 -0000	1.52
--- mips-tfile.c	24 May 2003 12:32:45 -0000
*************** enum alloc_type {
*** 895,907 ****
     pages.  On systems with a BSD malloc that define USE_MALLOC, the
     MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc
     adds its overhead, and rounds up to the next power of 2.  Pages are
!    linked together via a linked list.
!
!    If PAGE_SIZE is > 4096, the string length in the shash_t structure
!    can't be represented (assuming there are strings > 4096 bytes).  */

  #ifndef PAGE_SIZE
! #define PAGE_SIZE 4096		/* size of varray pages */
  #endif

  #define PAGE_USIZE ((Size_t) PAGE_SIZE)
--- 895,904 ----
     pages.  On systems with a BSD malloc that define USE_MALLOC, the
     MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc
     adds its overhead, and rounds up to the next power of 2.  Pages are
!    linked together via a linked list.  */

  #ifndef PAGE_SIZE
! #define PAGE_SIZE 32768		/* size of varray pages */
  #endif

  #define PAGE_USIZE ((Size_t) PAGE_SIZE)


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]