aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-11-10 16:23:12 -0500
committerJason Merrill <jason@redhat.com>2021-11-16 17:35:15 -0500
commit395848255cfa88f6f0f33a9b14c79e584a05d6fc (patch)
tree2da3124e22bf61524abb557a9c0b83fab2e211ed /gcc/c-family
parent6dc90c4dbb6f9589dea9c670c3468496bb207de5 (diff)
downloadgcc-395848255cfa88f6f0f33a9b14c79e584a05d6fc.zip
gcc-395848255cfa88f6f0f33a9b14c79e584a05d6fc.tar.gz
gcc-395848255cfa88f6f0f33a9b14c79e584a05d6fc.tar.bz2
c-family: don't cache large vecs
Patrick observed recently that an element of the vector cache could be arbitrarily large. Let's only cache relatively small vecs. gcc/c-family/ChangeLog: * c-common.c (release_tree_vector): Only cache vecs smaller than 16 elements.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-common.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 436df45..90e8ec8 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -8213,8 +8213,16 @@ release_tree_vector (vec<tree, va_gc> *vec)
{
if (vec != NULL)
{
- vec->truncate (0);
- vec_safe_push (tree_vector_cache, vec);
+ if (vec->allocated () >= 16)
+ /* Don't cache vecs that have expanded more than once. On a p64
+ target, vecs double in alloc size with each power of 2 elements, e.g
+ at 16 elements the alloc increases from 128 to 256 bytes. */
+ vec_free (vec);
+ else
+ {
+ vec->truncate (0);
+ vec_safe_push (tree_vector_cache, vec);
+ }
}
}