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] shrink some cp/parser.c structures


Some structures in cp/parserc.c can be made smaller by using enum
bitfields. 

Before this patch, on a 32bit machine, sizeof (struct cp_token_block) = 652 
so ggc-page.c would allocate a cp_token_block on a 1024 byte page,
resulting in a lot of overhead. This patch tries to make sure that
struct cp_token_block would fit in a 512B block. Is that OK, or is
1024B better? 

If the patch is OK, please apply it, I don't have CVS commit access.


2003-06-23  Dan Nicolaescu  <dann@ics.uci.edu>

	* parser.c (struct cp_token): Use enum bitfields.
	(CP_TOKEN_BLOCK_NUM_TOKENS): Make sure cp_token_block fits in a
	512B allocation unit.
	(cp_parser_token_tree_map_node): Use enum bitfields.

Index: parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.63
diff -c -3 -p -r1.63 parser.c
*** parser.c	25 May 2003 12:59:22 -0000	1.63
--- parser.c	23 Jun 2003 23:57:15 -0000
***************
*** 68,86 ****
  typedef struct cp_token GTY (())
  {
    /* The kind of token.  */
!   enum cpp_ttype type;
!   /* The value associated with this token, if any.  */
!   tree value;
    /* If this token is a keyword, this value indicates which keyword.
       Otherwise, this value is RID_MAX.  */
!   enum rid keyword;
    /* The location at which this token was found.  */
    location_t location;
  } cp_token;
  
! /* The number of tokens in a single token block.  */
  
! #define CP_TOKEN_BLOCK_NUM_TOKENS 32
  
  /* A group of tokens.  These groups are chained together to store
     large numbers of tokens.  (For example, a token block is created
--- 68,87 ----
  typedef struct cp_token GTY (())
  {
    /* The kind of token.  */
!   enum cpp_ttype type : 8;
    /* If this token is a keyword, this value indicates which keyword.
       Otherwise, this value is RID_MAX.  */
!   enum rid keyword : 8;
!   /* The value associated with this token, if any.  */
!   tree value;
    /* The location at which this token was found.  */
    location_t location;
  } cp_token;
  
! /* The number of tokens in a single token block.
!    Computed so that cp_token_block fits in a 512B allocation unit.  */
  
! #define CP_TOKEN_BLOCK_NUM_TOKENS ((512 - 3*sizeof (char*))/sizeof (cp_token))
  
  /* A group of tokens.  These groups are chained together to store
     large numbers of tokens.  (For example, a token block is created
*************** typedef enum cp_parser_declarator_kind
*** 1122,1130 ****
  typedef struct cp_parser_token_tree_map_node
  {
    /* The token type.  */
!   enum cpp_ttype token_type;
    /* The corresponding tree code.  */
!   enum tree_code tree_type;
  } cp_parser_token_tree_map_node;
  
  /* A complete map consists of several ordinary entries, followed by a
--- 1123,1131 ----
  typedef struct cp_parser_token_tree_map_node
  {
    /* The token type.  */
!   enum cpp_ttype token_type : 8;
    /* The corresponding tree code.  */
!   enum tree_code tree_type : 8;
  } cp_parser_token_tree_map_node;
  
  /* A complete map consists of several ordinary entries, followed by a


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