[PATCH] Increase PAGESIZE in mips-tfile.c

Roger Sayle roger@eyesopen.com
Fri May 23 04:48:00 GMT 2003


The following patch increases the PAGE_SIZE used for memory allocation
in mips-tfile.c from 4K to 8K.  mips-tfile allocates memory in chunks
of "page size" at a time, including for use by its string hash-table.
This then places a restriction on the maximum size of a string that
can be recorded in the hash-table.

Unfortunately, the current 4K limit causes a build failure on
alphaev67-dec-osf5.1 for one of OpenEye's C++ libraries which when
compiled with -g for debugging dies with the error message:

mips-tfile, /tmp//ccj5lJjW.s:353 string too big (4288 bytes)
line:    #.stabs        "1795=#1745,28,1750,1743,24;:_ZNSt8_Rb_treeISsSt4pairIKS
sS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC
_EE5eraseERS1_;2A.1796=#1745,24,1750,1770,1770,24;:_ZNSt8_Rb_treeISsSt4pairIKSsS
0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC_E
E5eraseESt17_Rb_tree_iteratorISC_RSC_PSC_ESM_;2A.1797=#1745,24,1750,1798=*1744,1
798,24;:_ZNSt8_Rb_treeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEE
St10_Select1stISC_ESt4lessISsESaISC_EE5eraseEPS1_SJ_;2A.;clear::1772:_ZNSt8_Rb_t
reeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_E
St4lessISsESaISC_EE5clearEv;2A.;find::1799=#1745,1770,1750,1743,24;:_ZNSt8_Rb_tr
eeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ES
t4lessISsESaISC_EE4findERS1_;2A.1800=#1745,1782,1747,1743,24;:_ZNKSt8_Rb_treeISs
St4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ESt4les
sISsESaISC_EE4findERS1_;2B.;count::1801=#1745,28,1747,1743,24;:_ZNKSt8_Rb_treeIS
sSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ESt4le
ssISsESaISC_EE5countERS1_;2B.;lower_bound::1799:_ZNSt8_Rb_treeISsSt4pairIKSsS0_I
PFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC_EE11
lower_boundERS1_;2A.1800:_ZNKSt8_Rb_treeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeist
reamEPKcEPFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC_EE11lower_boundERS1_;2B.;u
pper_bound::1799:_ZNSt8_Rb_treeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcE
PFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC_EE11upper_boundERS1_;2A.1800:_ZNKSt
8_Rb_treeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKcEPFvS4_EEESt10_Select1s
tISC_ESt4lessISsESaISC_EE11upper_boundERS1_;2B.;equal_range::1802=#1745,1803=xsp
...
d::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<
OEPlatform::oeistream*(*)(const char*), void (*)(OEPlatform::oeistream*)> >*>,st
d::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<ch
ar>, std::allocator<char> >, std::pair<OEPlatform::oeistream*(*)(const char*), v
oid (*)(OEPlatform::oeistream*)> >, const std::pair<const std::basic_string<char
, std::char_traits<char>, std::allocator<char> >, std::pair<OEPlatform::oeistrea
m*(*)(const char*), void (*)(OEPlatform::oeistream*)> >&, const std::pair<const
std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pai
r<OEPlatform::oeistream*(*)(const char*), void (*)(OEPlatform::oeistream*)> >*>
>:,1747,1743,24;:_ZNKSt8_Rb_treeISsSt4pairIKSsS0_IPFPN10OEPlatform9oeistreamEPKc
EPFvS4_EEESt10_Select1stISC_ESt4lessISsESaISC_EE11equal_rangeERS1_;2B.;\\",128,0
,0,0


The library and all the applications that depend upon it build fine
when compiled without debugging information turned on with -g.

In addition to considering typedefs to reduce the above .stabs line,
I also investigated the source of this limit, which as mentioned above
is caused by the value of PAGE_SIZE in mips-tfile.c.  The obvious fix
on GCC's side is to simply double it from the current value of 4K to a
more reasonable 8K, which should probably be enough for the next 12
years.

The story would end here if it wasn't for the cryptic comment
immediately above the declaration for PAGE_SIZE in the mips-tfile.c
source code.  This explains that if PAGE_SIZE > 4096, then the
string's length can't be represented in the shash_t structure!?

The definition of shash_t in mips-tfile is:

/* Master type for indexes within the symbol table.  */
typedef unsigned long symint_t;

typedef struct shash {
  struct shash  *next;          /* next hash value */
  char          *string;        /* string we are hashing */
  symint_t       len;           /* string length */
  symint_t       indx;          /* index within string table */
  EXTR          *esym_ptr;      /* global symbol pointer */
  SYMR          *sym_ptr;       /* local symbol pointer */
  SYMR          *end_ptr;       /* symbol pointer to end block */
  tag_t         *tag_ptr;       /* tag pointer */
  PDR           *proc_ptr;      /* procedure descriptor pointer */
} shash_t;


Which certainly looks like it no longer has a 4096 byte limit.  Indeed
I scoured to entire mips-tfile.c source code without being able to find
where such a restriction could originally have come from.  The are no
other references to 4096, 4095, shifts 12 bits, etc...  Indeed, the
code doesn't appear to have a size restriction beyond unsigned long.
Indeed bootstrapping and regression testing on the only OS that uses
mips-tfile works perfectly with a value of 8192.

I then tried some archeology.  It turns out that the same comment
is present, the page size is defined to 4096 and the declaration of
shash_t and symint_t are the effectively the same when CVS started
in 1997.  Prior to this the code is still identical back in gcc
2.5.8 (Jan 1994) which is the oldest version of mips-tfile.c that
I could find.  I'm guessing that if the comment was ever meaningful
it was only for the original code prior to Michael Meissner first
adding it to gcc on Tuesday May 28th 1991.

My conclusion: The comment is bogus.


The following patch has been tested on alphaev67-dec-osf5.1 with a
full "make bootstrap", all languages except ada and treelang, and
regression tested with a top-level "make -k check" with no new
failures.  Unfortunately, the source code that triggers the problem
is proprietary, but I can confirm that it now builds with -g with
this patch applied, but fails to compile without it.  mips-tfile.c
is only built on Tru64 and the only code that should be affected
by this patch is code that would have failed to compile previously.

Ok for mainline?


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

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


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	21 May 2003 21:57:16 -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 8192		/* 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



More information about the Gcc-patches mailing list