Commit a260bce6 by Matt Austern Committed by Matt Austern

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
parent d0940a55
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> 2003-03-19 Nathanael Nerode <neroden@gcc.gnu.org>
* dump.c (cp_dump_tree), cp-tree.h (cp_dump_tree): Change return * dump.c (cp_dump_tree), cp-tree.h (cp_dump_tree): Change return
......
...@@ -4062,14 +4062,16 @@ extern void init_repo (const char *); ...@@ -4062,14 +4062,16 @@ extern void init_repo (const char *);
extern void finish_repo (void); extern void finish_repo (void);
/* in rtti.c */ /* 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 void init_rtti_processing (void);
extern tree build_typeid (tree); extern tree build_typeid (tree);
extern tree get_tinfo_decl (tree); extern tree get_tinfo_decl (tree);
extern tree get_typeid (tree); extern tree get_typeid (tree);
extern tree build_dynamic_cast (tree, tree); extern tree build_dynamic_cast (tree, tree);
extern void emit_support_tinfos (void); extern void emit_support_tinfos (void);
extern bool unemitted_tinfo_decl_p (tree, void *); extern bool emit_tinfo_decl (tree);
extern bool emit_tinfo_decl (tree *, void *);
/* in search.c */ /* in search.c */
extern tree lookup_base (tree, tree, base_access, base_kind *); extern tree lookup_base (tree, tree, base_access, base_kind *);
......
...@@ -2595,6 +2595,7 @@ finish_file () ...@@ -2595,6 +2595,7 @@ finish_file ()
do do
{ {
tree t; tree t;
size_t n_old, n_new;
reconsider = false; reconsider = false;
...@@ -2611,7 +2612,7 @@ finish_file () ...@@ -2611,7 +2612,7 @@ finish_file ()
while (keyed_classes != NULL_TREE while (keyed_classes != NULL_TREE
&& maybe_emit_vtables (TREE_VALUE (keyed_classes))) && maybe_emit_vtables (TREE_VALUE (keyed_classes)))
{ {
reconsider = 1; reconsider = true;
keyed_classes = TREE_CHAIN (keyed_classes); keyed_classes = TREE_CHAIN (keyed_classes);
} }
...@@ -2624,7 +2625,7 @@ finish_file () ...@@ -2624,7 +2625,7 @@ finish_file ()
{ {
if (maybe_emit_vtables (TREE_VALUE (next))) if (maybe_emit_vtables (TREE_VALUE (next)))
{ {
reconsider = 1; reconsider = true;
TREE_CHAIN (t) = TREE_CHAIN (next); TREE_CHAIN (t) = TREE_CHAIN (next);
} }
else else
...@@ -2634,10 +2635,34 @@ finish_file () ...@@ -2634,10 +2635,34 @@ finish_file ()
} }
} }
/* Write out needed type info variables. Writing out one variable /* Write out needed type info variables. We have to be careful
might cause others to be needed. */ looping through unemitted decls, because emit_tinfo_decl may
if (walk_globals (unemitted_tinfo_decl_p, emit_tinfo_decl, /*data=*/0)) 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; 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 /* The list of objects with static storage duration is built up
in reverse order. We clear STATIC_AGGREGATES so that any new in reverse order. We clear STATIC_AGGREGATES so that any new
......
...@@ -73,6 +73,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -73,6 +73,9 @@ Boston, MA 02111-1307, USA. */
/* The IDENTIFIER_NODE naming the real class. */ /* The IDENTIFIER_NODE naming the real class. */
#define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE) #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 build_headof PARAMS((tree));
static tree ifnonnull PARAMS((tree, tree)); static tree ifnonnull PARAMS((tree, tree));
static tree tinfo_name PARAMS((tree)); static tree tinfo_name PARAMS((tree));
...@@ -97,6 +100,7 @@ static tree get_pseudo_ti_init PARAMS ((tree, tree, bool *)); ...@@ -97,6 +100,7 @@ static tree get_pseudo_ti_init PARAMS ((tree, tree, bool *));
static tree get_pseudo_ti_desc PARAMS((tree)); static tree get_pseudo_ti_desc PARAMS((tree));
static void create_tinfo_types PARAMS((void)); static void create_tinfo_types PARAMS((void));
static bool typeinfo_in_lib_p (tree); static bool typeinfo_in_lib_p (tree);
static bool unemitted_tinfo_decl_p PARAMS((tree));
static int doing_runtime = 0; static int doing_runtime = 0;
...@@ -122,6 +126,8 @@ init_rtti_processing (void) ...@@ -122,6 +126,8 @@ init_rtti_processing (void)
type_info_ptr_type = build_pointer_type (const_type_info_type); type_info_ptr_type = build_pointer_type (const_type_info_type);
type_info_ref_type = build_reference_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 (); create_tinfo_types ();
} }
...@@ -367,6 +373,10 @@ get_tinfo_decl (tree type) ...@@ -367,6 +373,10 @@ get_tinfo_decl (tree type)
/* Remember the type it is for. */ /* Remember the type it is for. */
TREE_TYPE (name) = type; 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; return d;
...@@ -1403,8 +1413,8 @@ emit_support_tinfos (void) ...@@ -1403,8 +1413,8 @@ emit_support_tinfos (void)
/* Return true, iff T is a type_info variable which has not had a /* Return true, iff T is a type_info variable which has not had a
definition emitted for it. */ definition emitted for it. */
bool static bool
unemitted_tinfo_decl_p (tree t, void *data ATTRIBUTE_UNUSED) unemitted_tinfo_decl_p (tree t)
{ {
if (/* It's a var decl */ if (/* It's a var decl */
TREE_CODE (t) == VAR_DECL TREE_CODE (t) == VAR_DECL
...@@ -1429,14 +1439,15 @@ unemitted_tinfo_decl_p (tree t, void *data ATTRIBUTE_UNUSED) ...@@ -1429,14 +1439,15 @@ unemitted_tinfo_decl_p (tree t, void *data ATTRIBUTE_UNUSED)
generate the initializer. */ generate the initializer. */
bool 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)); tree type = TREE_TYPE (DECL_NAME (decl));
bool non_public; bool non_public;
int in_library = typeinfo_in_lib_p (type); int in_library = typeinfo_in_lib_p (type);
tree var_desc, var_init; tree var_desc, var_init;
my_friendly_assert (unemitted_tinfo_decl_p (decl), 20030307);
import_export_tinfo (decl, type, in_library); import_export_tinfo (decl, type, in_library);
if (DECL_REALLY_EXTERN (decl) || !DECL_NEEDED_P (decl)) if (DECL_REALLY_EXTERN (decl) || !DECL_NEEDED_P (decl))
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment