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]

[C++ PATCH] Kill lang_id2


Hi,

I don't understand the idea behind lang_id2 in the C++ lang_identifier. 
The total size of the language identifier is 48 bytes, which puts it in
a 64 byte bucket for the ggc-page.  Why not just use the extra 16 bytes
instead of linking to another tree?
Maybe this was a result of the recent name lookup changes?  There is a
bucket for 44 bytes objects, so if somebody added a field to
lang_identifier, that would explain.

Anyway, I'm testing this patch now.  It would kill a pointer deref, and
it should save some memory.  OK when it passes bootstrap/regtest?

Greetz
Steven


2003-04-30  Steven Bosscher  <steven@gcc.gnu.org>

	* cp-tree.h (struct lang_id2): Remove.  Move fields from here...
	(struct lang_identifier): ... to here.
	(LANG_ID_FIELD): Remove.
	(SET_LANG_ID): Remove.
	(IDENTIFIER_LABEL_VALUE): Adjust for new lang_identifier.
	(SET_IDENTIFIER_LABEL_VALUE): Likewise.
	(IDENTIFIER_IMPLICIT_DECL): Likewise.
	(SET_IDENTIFIERL_IMPLICIT_DECL): Likewise.
	(IDENTIFIER_ERROR_LOCUS): Likewise.
	(SET_IDENTIFIER_ERROR_LOCUS): Likewise.

Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.841
diff -c -3 -p -r1.841 cp-tree.h
*** cp-tree.h	29 Apr 2003 18:00:20 -0000	1.841
--- cp-tree.h	30 Apr 2003 19:29:19 -0000
*************** struct lang_identifier GTY(())
*** 224,230 ****
    cxx_binding *bindings;
    tree class_value;
    tree class_template_info;
!   struct lang_id2 *x;
  };
  
  /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
--- 224,232 ----
    cxx_binding *bindings;
    tree class_value;
    tree class_template_info;
!   tree label_value;
!   tree implicit_decl;
!   tree error_locus;
  };
  
  /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
*************** struct lang_identifier GTY(())
*** 236,248 ****
  #define LANG_IDENTIFIER_CAST(NODE) \
  	((struct lang_identifier*)IDENTIFIER_NODE_CHECK (NODE))
  
- struct lang_id2 GTY(())
- {
-   tree label_value;
-   tree implicit_decl;
-   tree error_locus;
- };
- 
  typedef struct template_parm_index_s GTY(())
  {
    struct tree_common common;
--- 238,243 ----
*************** struct tree_wrapper GTY(())
*** 392,421 ****
  #define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
  #define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
  
- #define LANG_ID_FIELD(NAME, NODE)			\
-   (LANG_IDENTIFIER_CAST (NODE)->x			\
-    ? LANG_IDENTIFIER_CAST (NODE)->x->NAME : 0)
- 
- #define SET_LANG_ID(NODE, VALUE, NAME)					     \
-   (LANG_IDENTIFIER_CAST (NODE)->x == 0					     \
-    ? LANG_IDENTIFIER_CAST (NODE)->x					     \
-       = (struct lang_id2 *)ggc_alloc_cleared (sizeof (struct lang_id2)) : 0, \
-    LANG_IDENTIFIER_CAST (NODE)->x->NAME = (VALUE))
- 
  #define IDENTIFIER_LABEL_VALUE(NODE) \
!   LANG_ID_FIELD (label_value, NODE)
  #define SET_IDENTIFIER_LABEL_VALUE(NODE, VALUE)   \
!   SET_LANG_ID (NODE, VALUE, label_value)
  
  #define IDENTIFIER_IMPLICIT_DECL(NODE) \
!   LANG_ID_FIELD (implicit_decl, NODE)
  #define SET_IDENTIFIER_IMPLICIT_DECL(NODE, VALUE) \
!   SET_LANG_ID (NODE, VALUE, implicit_decl)
  
  #define IDENTIFIER_ERROR_LOCUS(NODE) \
!   LANG_ID_FIELD (error_locus, NODE)
  #define SET_IDENTIFIER_ERROR_LOCUS(NODE, VALUE)	\
!   SET_LANG_ID (NODE, VALUE, error_locus)
  
  /* Nonzero if this identifier is used as a virtual function name somewhere
     (optimizes searches).  */
--- 387,406 ----
  #define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
  #define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
  
  #define IDENTIFIER_LABEL_VALUE(NODE) \
!   (LANG_IDENTIFIER_CAST (NODE)->label_value)
  #define SET_IDENTIFIER_LABEL_VALUE(NODE, VALUE)   \
!   LANG_IDENTIFIER_LABEL_VALUE (NODE) = (VALUE)
  
  #define IDENTIFIER_IMPLICIT_DECL(NODE) \
!   (LANG_IDENTIFIER_CAST (NODE)->implicit_decl)
  #define SET_IDENTIFIER_IMPLICIT_DECL(NODE, VALUE) \
!   LANG_IDENTIFIER_IMPLICIT_DECL (NODE) = (VALUE)
  
  #define IDENTIFIER_ERROR_LOCUS(NODE) \
!   (LANG_IDENTIFIER_CAST (NODE)->error_locus)
  #define SET_IDENTIFIER_ERROR_LOCUS(NODE, VALUE)	\
!   LANG_IDENTIFIER_ERROR_LOCUS (NODE) = (VALUE)
  
  /* Nonzero if this identifier is used as a virtual function name somewhere
     (optimizes searches).  */

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