+2019-07-20 Jason Merrill <jason@redhat.com>
+
+ Reduce memory consumption for push/pop_access_scope.
+ * name-lookup.c (leave_scope): Do add class levels other than
+ previous_class_level to free_binding_level.
+ (invalidate_class_lookup_cache): Move from class.c, add to
+ free_binding_level.
+ * pt.c (saved_access_scope): Change from list to vec.
+
2019-07-20 Jakub Jelinek <jakub@redhat.com>
* cp-tree.h (OMP_FOR_GIMPLIFYING_P): Use OMP_LOOPING_CHECK
restore_class_cache ();
}
-/* When we exit a toplevel class scope, we save its binding level so
- that we can restore it quickly. Here, we've entered some other
- class, so we must invalidate our cache. */
-
-void
-invalidate_class_lookup_cache (void)
-{
- previous_class_level = NULL;
-}
-
/* Get out of the current class scope. If we were in a class scope
previously, that is the one popped to. */
namespace. For classes, we cache some binding levels. For other
scopes, we just make the structure available for reuse. */
if (scope->kind != sk_namespace
- && scope->kind != sk_class)
+ && scope != previous_class_level)
{
scope->level_chain = free_binding_level;
gcc_assert (!ENABLE_SCOPE_CHECKING
return current_binding_level;
}
+/* When we exit a toplevel class scope, we save its binding level so
+ that we can restore it quickly. Here, we've entered some other
+ class, so we must invalidate our cache. */
+
+void
+invalidate_class_lookup_cache (void)
+{
+ previous_class_level->level_chain = free_binding_level;
+ free_binding_level = previous_class_level;
+ previous_class_level = NULL;
+}
+
static void
resume_scope (cp_binding_level* b)
{
static GTY(()) struct tinst_level *current_tinst_level;
-static GTY(()) tree saved_access_scope;
+static GTY(()) vec<tree, va_gc> *saved_access_scope;
/* Live only within one (recursive) call to tsubst_expr. We use
this to pass the statement expression node from the STMT_EXPR
if (TREE_CODE (t) == FUNCTION_DECL)
{
- saved_access_scope = tree_cons
- (NULL_TREE, current_function_decl, saved_access_scope);
+ vec_safe_push (saved_access_scope, current_function_decl);
current_function_decl = t;
}
}
pop_access_scope (tree t)
{
if (TREE_CODE (t) == FUNCTION_DECL)
- {
- current_function_decl = TREE_VALUE (saved_access_scope);
- saved_access_scope = TREE_CHAIN (saved_access_scope);
- }
+ current_function_decl = saved_access_scope->pop();
if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t))
pop_nested_class ();