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++] Vectorize unemitted_tinfo_decls


I noticed unemitted_tinfo_decls could be vectorized, so I did.
I picked the initial vector size by compiling a program that #included
iostream and vector.

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-09-22  Nathan Sidwell  <nathan@codesourcery.com>

	* cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree).
	* decl2.c (cp_finish_file): Adjust tinfo decl emission loop.
	* rtti.c (unemitted_tinfo_decls): Make a VEC(tree).
	(init_rtti_processing): Initialize it to something realistic.
	(get_tinfo_decl): Adjust pushing the new decl.

Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.1051
diff -c -3 -p -r1.1051 cp-tree.h
*** cp/cp-tree.h	22 Sep 2004 10:55:18 -0000	1.1051
--- cp/cp-tree.h	22 Sep 2004 12:50:50 -0000
*************** extern bool repo_export_class_p (tree);
*** 3967,3974 ****
  extern void finish_repo (void);
  
  /* in rtti.c */
! /* A varray of all tinfo decls that haven't been emitted yet.  */
! extern GTY(()) varray_type unemitted_tinfo_decls;
  
  extern void init_rtti_processing (void);
  extern tree build_typeid (tree);
--- 3967,3974 ----
  extern void finish_repo (void);
  
  /* in rtti.c */
! /* A vector of all tinfo decls that haven't been emitted yet.  */
! extern GTY(()) VEC(tree) *unemitted_tinfo_decls;
  
  extern void init_rtti_processing (void);
  extern tree build_typeid (tree);
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.748
diff -c -3 -p -r1.748 decl2.c
*** cp/decl2.c	21 Sep 2004 15:38:56 -0000	1.748
--- cp/decl2.c	22 Sep 2004 12:50:57 -0000
*************** cp_finish_file (void)
*** 2780,2786 ****
    do 
      {
        tree t;
-       size_t n_old, n_new;
  
        reconsider = false;
  
--- 2780,2785 ----
*************** cp_finish_file (void)
*** 2823,2854 ****
  
        /* Write out needed type info variables.  We have to be careful
   	 looping through unemitted decls, because emit_tinfo_decl may
!  	 cause other variables to be needed.  We stick new elements
!  	 (and old elements that we may need to reconsider) at the end
!  	 of the array, then shift them back to the beginning once we're
!  	 done.  */
! 
!       n_old = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls);
!       for (i = 0; i < n_old; ++i)
!   	{
!   	  tree tinfo_decl = VARRAY_TREE (unemitted_tinfo_decls, i);
!   	  if (emit_tinfo_decl (tinfo_decl))
!  	    reconsider = true;
!   	  else
!   	    VARRAY_PUSH_TREE (unemitted_tinfo_decls, tinfo_decl);
!   	}
!   
!       /* The only elements we want to keep are the new ones.  Copy
!   	 them to the beginning of the array, then get rid of the
!   	 leftovers.  */
!       n_new = VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) - n_old;
!       if (n_new)
! 	memmove (&VARRAY_TREE (unemitted_tinfo_decls, 0),
! 		 &VARRAY_TREE (unemitted_tinfo_decls, n_old),
! 		 n_new * sizeof (tree));
!       memset (&VARRAY_TREE (unemitted_tinfo_decls, n_new),
!   	      0, n_old * sizeof (tree));
!       VARRAY_ACTIVE_SIZE (unemitted_tinfo_decls) = n_new;
  
        /* The list of objects with static storage duration is built up
  	 in reverse order.  We clear STATIC_AGGREGATES so that any new
--- 2822,2837 ----
  
        /* Write out needed type info variables.  We have to be careful
   	 looping through unemitted decls, because emit_tinfo_decl may
!  	 cause other variables to be needed. New elements will be
!  	 appended, and we remove from the vector those that actually
!  	 get emitted.  */
!       for (i = VEC_length (tree, unemitted_tinfo_decls);
! 	   VEC_iterate (tree, unemitted_tinfo_decls, --i, t);)
! 	if (emit_tinfo_decl (t))
! 	  {
! 	    reconsider = true;
! 	    VEC_unordered_remove (tree, unemitted_tinfo_decls, i);
! 	  }
  
        /* The list of objects with static storage duration is built up
  	 in reverse order.  We clear STATIC_AGGREGATES so that any new
Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.199
diff -c -3 -p -r1.199 rtti.c
*** cp/rtti.c	22 Sep 2004 10:55:21 -0000	1.199
--- cp/rtti.c	22 Sep 2004 12:50:59 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 73,80 ****
  /* The IDENTIFIER_NODE naming the real class.  */
  #define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE)
  
! /* A varray of all tinfo decls that haven't yet been emitted.  */
! varray_type unemitted_tinfo_decls;
  
  static tree build_headof (tree);
  static tree ifnonnull (tree, tree);
--- 73,80 ----
  /* The IDENTIFIER_NODE naming the real class.  */
  #define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE)
  
! /* A vector of all tinfo decls that haven't yet been emitted.  */
! VEC (tree) *unemitted_tinfo_decls;
  
  static tree build_headof (tree);
  static tree ifnonnull (tree, tree);
*************** init_rtti_processing (void)
*** 120,127 ****
    type_info_ptr_type = build_pointer_type (const_type_info_type);
    type_info_ref_type = build_reference_type (const_type_info_type);
  
!   VARRAY_TREE_INIT (unemitted_tinfo_decls, 10, "RTTI decls");
! 
    create_tinfo_types ();
  }
  
--- 120,127 ----
    type_info_ptr_type = build_pointer_type (const_type_info_type);
    type_info_ref_type = build_reference_type (const_type_info_type);
  
!   unemitted_tinfo_decls = VEC_alloc (tree, 124);
!   
    create_tinfo_types ();
  }
  
*************** get_tinfo_decl (tree type)
*** 361,368 ****
        pushdecl_top_level_and_finish (d, NULL_TREE);
  
        /* Add decl to the global array of tinfo decls.  */
!       gcc_assert (unemitted_tinfo_decls != 0);
!       VARRAY_PUSH_TREE (unemitted_tinfo_decls, d);
      }
  
    return d;
--- 361,367 ----
        pushdecl_top_level_and_finish (d, NULL_TREE);
  
        /* Add decl to the global array of tinfo decls.  */
!       VEC_safe_push (tree, unemitted_tinfo_decls, d);
      }
  
    return d;

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