aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMatt Austern <austern@apple.com>2003-03-20 21:14:30 +0000
committerMatt Austern <austern@gcc.gnu.org>2003-03-20 21:14:30 +0000
commita260bce67642765094ec0bbfa3687876c7a2f51c (patch)
tree4beefd450f4f5c3baa474b410f8a4e40a2189ca2 /gcc/cp
parentd0940a55f800ad463e270ab8c86dfc53600a49a6 (diff)
downloadgcc-a260bce67642765094ec0bbfa3687876c7a2f51c.zip
gcc-a260bce67642765094ec0bbfa3687876c7a2f51c.tar.gz
gcc-a260bce67642765094ec0bbfa3687876c7a2f51c.tar.bz2
cp-tree.h (unemitted_tinfo_decls): Declaration of a new varray.
* cp-tree.h (unemitted_tinfo_decls): Declaration of a new varray. (unemitted_tinfo_decl_p): Remove. (emit_tinfo_decl): Change declaration to remove unused parameter. * decl2.c (finish_file): Change tinfo emission to loop through unemitted_tinfo_decls array instead of looping through all decls. * rtti.c (unemitted_tinfo_decl_p): Declare as static, remove unused second parameter. (init_rtti_processing): initialize unemitted_tinfo_decls varray. (get_tinfo_decls): push new tinfo decl on unemitted_tinfo_decls. (emit_tinfo_decl): remove unused second parameter, add assertion that decl hasn't already been emitted. From-SVN: r64621
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl2.c37
-rw-r--r--gcc/cp/rtti.c19
4 files changed, 64 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d5864cd..7c26348 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,17 @@
+2003-03-14 Matt Austern <austern@apple.com>
+
+ * cp-tree.h (unemitted_tinfo_decls): Declaration of a new varray.
+ (unemitted_tinfo_decl_p): Remove.
+ (emit_tinfo_decl): Change declaration to remove unused parameter.
+ * decl2.c (finish_file): Change tinfo emission to loop through
+ unemitted_tinfo_decls array instead of looping through all decls.
+ * rtti.c (unemitted_tinfo_decl_p): Declare as static, remove
+ unused second parameter.
+ (init_rtti_processing): initialize unemitted_tinfo_decls varray.
+ (get_tinfo_decls): push new tinfo decl on unemitted_tinfo_decls.
+ (emit_tinfo_decl): remove unused second parameter, add assertion
+ that decl hasn't already been emitted.
+
2003-03-19 Nathanael Nerode <neroden@gcc.gnu.org>
* dump.c (cp_dump_tree), cp-tree.h (cp_dump_tree): Change return
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index f8ded19..2a207a1 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4062,14 +4062,16 @@ extern void init_repo (const char *);
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);
extern tree get_tinfo_decl (tree);
extern tree get_typeid (tree);
extern tree build_dynamic_cast (tree, tree);
extern void emit_support_tinfos (void);
-extern bool unemitted_tinfo_decl_p (tree, void *);
-extern bool emit_tinfo_decl (tree *, void *);
+extern bool emit_tinfo_decl (tree);
/* in search.c */
extern tree lookup_base (tree, tree, base_access, base_kind *);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 9937e75..1ba80d7 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2595,6 +2595,7 @@ finish_file ()
do
{
tree t;
+ size_t n_old, n_new;
reconsider = false;
@@ -2611,7 +2612,7 @@ finish_file ()
while (keyed_classes != NULL_TREE
&& maybe_emit_vtables (TREE_VALUE (keyed_classes)))
{
- reconsider = 1;
+ reconsider = true;
keyed_classes = TREE_CHAIN (keyed_classes);
}
@@ -2624,7 +2625,7 @@ finish_file ()
{
if (maybe_emit_vtables (TREE_VALUE (next)))
{
- reconsider = 1;
+ reconsider = true;
TREE_CHAIN (t) = TREE_CHAIN (next);
}
else
@@ -2634,10 +2635,34 @@ finish_file ()
}
}
- /* Write out needed type info variables. Writing out one variable
- might cause others to be needed. */
- if (walk_globals (unemitted_tinfo_decl_p, emit_tinfo_decl, /*data=*/0))
- reconsider = true;
+ /* 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;
+ 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
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index eab85f7..a9a7cdb 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -73,6 +73,9 @@ 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;
+
static tree build_headof PARAMS((tree));
static tree ifnonnull PARAMS((tree, tree));
static tree tinfo_name PARAMS((tree));
@@ -97,6 +100,7 @@ static tree get_pseudo_ti_init PARAMS ((tree, tree, bool *));
static tree get_pseudo_ti_desc PARAMS((tree));
static void create_tinfo_types PARAMS((void));
static bool typeinfo_in_lib_p (tree);
+static bool unemitted_tinfo_decl_p PARAMS((tree));
static int doing_runtime = 0;
@@ -122,6 +126,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");
+
create_tinfo_types ();
}
@@ -367,6 +373,10 @@ get_tinfo_decl (tree type)
/* Remember the type it is for. */
TREE_TYPE (name) = type;
+
+ /* Add decl to the global array of tinfo decls. */
+ my_friendly_assert (unemitted_tinfo_decls != 0, 20030312);
+ VARRAY_PUSH_TREE (unemitted_tinfo_decls, d);
}
return d;
@@ -1403,8 +1413,8 @@ emit_support_tinfos (void)
/* Return true, iff T is a type_info variable which has not had a
definition emitted for it. */
-bool
-unemitted_tinfo_decl_p (tree t, void *data ATTRIBUTE_UNUSED)
+static bool
+unemitted_tinfo_decl_p (tree t)
{
if (/* It's a var decl */
TREE_CODE (t) == VAR_DECL
@@ -1429,13 +1439,14 @@ unemitted_tinfo_decl_p (tree t, void *data ATTRIBUTE_UNUSED)
generate the initializer. */
bool
-emit_tinfo_decl (tree *decl_ptr, void *data ATTRIBUTE_UNUSED)
+emit_tinfo_decl (tree decl)
{
- tree decl = *decl_ptr;
tree type = TREE_TYPE (DECL_NAME (decl));
bool non_public;
int in_library = typeinfo_in_lib_p (type);
tree var_desc, var_init;
+
+ my_friendly_assert (unemitted_tinfo_decl_p (decl), 20030307);
import_export_tinfo (decl, type, in_library);
if (DECL_REALLY_EXTERN (decl) || !DECL_NEEDED_P (decl))