From 942149531d595c7860a49a9688fd9cd160a62455 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 22 Sep 2004 18:12:10 +0000 Subject: [PATCH] cp-tree.h (unemitted_tinfo_decls): Make a VEC(tree). * 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. From-SVN: r87872 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 4 ++-- gcc/cp/decl2.c | 37 ++++++++++--------------------------- gcc/cp/rtti.c | 11 +++++------ 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f88f663fedf..e91d4251d8d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2004-09-22 Nathan Sidwell + * 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. + * cp-tree.h (struct lang_type_class): Remove marked flags, add diamond_shaped and repeated_base flags. Reorder to keep 8-bit blocks. (TYPE_MARKED_P): New. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 417d179ff0d..c439864c1b1 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3967,8 +3967,8 @@ extern bool repo_export_class_p (tree); 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; +/* 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); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0c05a7ad160..8506ea3b3b8 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2780,7 +2780,6 @@ cp_finish_file (void) do { tree t; - size_t n_old, n_new; reconsider = false; @@ -2823,32 +2822,16 @@ cp_finish_file (void) /* 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; + 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 diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 2dc05ad3cab..b995726e09b 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -73,8 +73,8 @@ Boston, MA 02111-1307, USA. */ /* 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; +/* 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); @@ -120,8 +120,8 @@ init_rtti_processing (void) 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"); - + unemitted_tinfo_decls = VEC_alloc (tree, 124); + create_tinfo_types (); } @@ -361,8 +361,7 @@ get_tinfo_decl (tree type) 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); + VEC_safe_push (tree, unemitted_tinfo_decls, d); } return d;