Commit 6a2dfd9a by Nathan Sidwell

Make keyed_classes a vector.

	* cp-tree.h (CPTI_KEYED_CLASSES, keyed_classes): Delete.
	(keyed_classes): Declare as vector.
	* decl.c (keyed_classes): Define.
	(cxx_init_decl_processing): Allocate it.
	(record_key_method_defined): Use vec_safe_push.
	* class.c (finish_struct_1): Likewise.
	* pt.c (instantiate_class_template_1): Likewise.
	* decl2.c (c_parse_final_cleanups): Reverse iterate keyed_classes.

From-SVN: r249263
parent 8c1ca7ee
...@@ -7189,8 +7189,8 @@ finish_struct_1 (tree t) ...@@ -7189,8 +7189,8 @@ finish_struct_1 (tree t)
in every translation unit where the class definition appears. If in every translation unit where the class definition appears. If
we're devirtualizing, we can look into the vtable even if we we're devirtualizing, we can look into the vtable even if we
aren't emitting it. */ aren't emitting it. */
if (CLASSTYPE_KEY_METHOD (t) == NULL_TREE) if (!CLASSTYPE_KEY_METHOD (t))
keyed_classes = tree_cons (NULL_TREE, t, keyed_classes); vec_safe_push (keyed_classes, t);
} }
/* Layout the class itself. */ /* Layout the class itself. */
......
...@@ -169,8 +169,6 @@ enum cp_tree_index ...@@ -169,8 +169,6 @@ enum cp_tree_index
CPTI_DSO_HANDLE, CPTI_DSO_HANDLE,
CPTI_DCAST, CPTI_DCAST,
CPTI_KEYED_CLASSES,
CPTI_NULLPTR, CPTI_NULLPTR,
CPTI_NULLPTR_TYPE, CPTI_NULLPTR_TYPE,
...@@ -290,11 +288,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; ...@@ -290,11 +288,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
destructors. */ destructors. */
#define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE] #define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
/* A TREE_LIST of the dynamic classes whose vtables may have to be
emitted in this translation unit. */
#define keyed_classes cp_global_trees[CPTI_KEYED_CLASSES]
/* A node which matches any template argument. */ /* A node which matches any template argument. */
#define any_targ_node cp_global_trees[CPTI_ANY_TARG] #define any_targ_node cp_global_trees[CPTI_ANY_TARG]
...@@ -5107,6 +5100,10 @@ extern GTY(()) vec<tree, va_gc> *local_classes; ...@@ -5107,6 +5100,10 @@ extern GTY(()) vec<tree, va_gc> *local_classes;
/* An array of static vars & fns. */ /* An array of static vars & fns. */
extern GTY(()) vec<tree, va_gc> *static_decls; extern GTY(()) vec<tree, va_gc> *static_decls;
/* An array of vtable-needing types that have no key function, or have
an emitted key function. */
extern GTY(()) vec<tree, va_gc> *keyed_classes;
/* Here's where we control how name mangling takes place. */ /* Here's where we control how name mangling takes place. */
......
...@@ -160,6 +160,9 @@ tree integer_two_node; ...@@ -160,6 +160,9 @@ tree integer_two_node;
/* vector of static decls. */ /* vector of static decls. */
vec<tree, va_gc> *static_decls; vec<tree, va_gc> *static_decls;
/* vector of keyed classes. */
vec<tree, va_gc> *keyed_classes;
/* Used only for jumps to as-yet undefined labels, since jumps to /* Used only for jumps to as-yet undefined labels, since jumps to
defined labels can have their validity checked immediately. */ defined labels can have their validity checked immediately. */
...@@ -4064,6 +4067,9 @@ cxx_init_decl_processing (void) ...@@ -4064,6 +4067,9 @@ cxx_init_decl_processing (void)
/* Guess at the initial static decls size. */ /* Guess at the initial static decls size. */
vec_alloc (static_decls, 500); vec_alloc (static_decls, 500);
/* ... and keyed classes. */
vec_alloc (keyed_classes, 100);
record_builtin_type (RID_BOOL, "bool", boolean_type_node); record_builtin_type (RID_BOOL, "bool", boolean_type_node);
truthvalue_type_node = boolean_type_node; truthvalue_type_node = boolean_type_node;
truthvalue_false_node = boolean_false_node; truthvalue_false_node = boolean_false_node;
...@@ -15438,7 +15444,7 @@ record_key_method_defined (tree fndecl) ...@@ -15438,7 +15444,7 @@ record_key_method_defined (tree fndecl)
{ {
tree fnclass = DECL_CONTEXT (fndecl); tree fnclass = DECL_CONTEXT (fndecl);
if (fndecl == CLASSTYPE_KEY_METHOD (fnclass)) if (fndecl == CLASSTYPE_KEY_METHOD (fnclass))
keyed_classes = tree_cons (NULL_TREE, fnclass, keyed_classes); vec_safe_push (keyed_classes, fnclass);
} }
} }
......
...@@ -4511,37 +4511,18 @@ c_parse_final_cleanups (void) ...@@ -4511,37 +4511,18 @@ c_parse_final_cleanups (void)
instantiate_pending_templates (retries); instantiate_pending_templates (retries);
ggc_collect (); ggc_collect ();
/* Write out virtual tables as required. Note that writing out /* Write out virtual tables as required. Writing out the
the virtual table for a template class may cause the virtual table for a template class may cause the
instantiation of members of that class. If we write out instantiation of members of that class. If we write out
vtables then we remove the class from our list so we don't vtables then we remove the class from our list so we don't
have to look at it again. */ have to look at it again. */
for (i = keyed_classes->length ();
while (keyed_classes != NULL_TREE keyed_classes->iterate (--i, &t);)
&& maybe_emit_vtables (TREE_VALUE (keyed_classes))) if (maybe_emit_vtables (t))
{ {
reconsider = true; reconsider = true;
keyed_classes = TREE_CHAIN (keyed_classes); keyed_classes->unordered_remove (i);
} }
t = keyed_classes;
if (t != NULL_TREE)
{
tree next = TREE_CHAIN (t);
while (next)
{
if (maybe_emit_vtables (TREE_VALUE (next)))
{
reconsider = true;
TREE_CHAIN (t) = TREE_CHAIN (next);
}
else
t = next;
next = TREE_CHAIN (t);
}
}
/* Write out needed type info variables. We have to be careful /* Write out needed type info variables. We have to be careful
looping through unemitted decls, because emit_tinfo_decl may looping through unemitted decls, because emit_tinfo_decl may
......
...@@ -10864,9 +10864,9 @@ instantiate_class_template_1 (tree type) ...@@ -10864,9 +10864,9 @@ instantiate_class_template_1 (tree type)
/* The vtable for a template class can be emitted in any translation /* The vtable for a template class can be emitted in any translation
unit in which the class is instantiated. When there is no key unit in which the class is instantiated. When there is no key
method, however, finish_struct_1 will already have added TYPE to method, however, finish_struct_1 will already have added TYPE to
the keyed_classes list. */ the keyed_classes. */
if (TYPE_CONTAINS_VPTR_P (type) && CLASSTYPE_KEY_METHOD (type)) if (TYPE_CONTAINS_VPTR_P (type) && CLASSTYPE_KEY_METHOD (type))
keyed_classes = tree_cons (NULL_TREE, type, keyed_classes); vec_safe_push (keyed_classes, type);
return type; return type;
} }
......
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