aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libbacktrace
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-05-17 17:03:43 -0700
committerBen Cheng <bccheng@google.com>2014-05-17 17:12:35 -0700
commit8c493ead6366b552adee796de296936b78f34c5a (patch)
tree4936e52fb9b84edbcd9293bd321027413d1835bf /gcc-4.9/libbacktrace
parent9750bde7e561731ce8a07cdbd0165a688e74a696 (diff)
downloadtoolchain_gcc-8c493ead6366b552adee796de296936b78f34c5a.tar.gz
toolchain_gcc-8c493ead6366b552adee796de296936b78f34c5a.tar.bz2
toolchain_gcc-8c493ead6366b552adee796de296936b78f34c5a.zip
[4.9] Refresh GCC 4.9 to the 20140514 snapshot.
For critical bug fixes including devirtualization and codegen. Change-Id: I8138d3dc408fc12db5eecb01d2753d39219712f2
Diffstat (limited to 'gcc-4.9/libbacktrace')
-rw-r--r--gcc-4.9/libbacktrace/ChangeLog9
-rw-r--r--gcc-4.9/libbacktrace/mmap.c28
2 files changed, 35 insertions, 2 deletions
diff --git a/gcc-4.9/libbacktrace/ChangeLog b/gcc-4.9/libbacktrace/ChangeLog
index 5dfe80b38..8bcc677fd 100644
--- a/gcc-4.9/libbacktrace/ChangeLog
+++ b/gcc-4.9/libbacktrace/ChangeLog
@@ -1,3 +1,12 @@
+2014-05-08 Ian Lance Taylor <iant@google.com>
+
+ Backport from mainline:
+ * mmap.c (backtrace_free): If freeing a large aligned block of
+ memory, call munmap rather than holding onto it.
+ (backtrace_vector_grow): When growing a vector, double the number
+ of pages requested. When releasing the old version of a grown
+ vector, pass the correct size to backtrace_free.
+
2014-04-22 Release Manager
* GCC 4.9.0 released.
diff --git a/gcc-4.9/libbacktrace/mmap.c b/gcc-4.9/libbacktrace/mmap.c
index b530e3823..5a9f6299b 100644
--- a/gcc-4.9/libbacktrace/mmap.c
+++ b/gcc-4.9/libbacktrace/mmap.c
@@ -164,6 +164,26 @@ backtrace_free (struct backtrace_state *state, void *addr, size_t size,
{
int locked;
+ /* If we are freeing a large aligned block, just release it back to
+ the system. This case arises when growing a vector for a large
+ binary with lots of debug info. Calling munmap here may cause us
+ to call mmap again if there is also a large shared library; we
+ just live with that. */
+ if (size >= 16 * 4096)
+ {
+ size_t pagesize;
+
+ pagesize = getpagesize ();
+ if (((uintptr_t) addr & (pagesize - 1)) == 0
+ && (size & (pagesize - 1)) == 0)
+ {
+ /* If munmap fails for some reason, just add the block to
+ the freelist. */
+ if (munmap (addr, size) == 0)
+ return;
+ }
+ }
+
/* If we can acquire the lock, add the new space to the free list.
If we can't acquire the lock, just leak the memory.
__sync_lock_test_and_set returns the old state of the lock, so we
@@ -209,14 +229,18 @@ backtrace_vector_grow (struct backtrace_state *state,size_t size,
alc = pagesize;
}
else
- alc = (alc + pagesize - 1) & ~ (pagesize - 1);
+ {
+ alc *= 2;
+ alc = (alc + pagesize - 1) & ~ (pagesize - 1);
+ }
base = backtrace_alloc (state, alc, error_callback, data);
if (base == NULL)
return NULL;
if (vec->base != NULL)
{
memcpy (base, vec->base, vec->size);
- backtrace_free (state, vec->base, vec->alc, error_callback, data);
+ backtrace_free (state, vec->base, vec->size + vec->alc,
+ error_callback, data);
}
vec->base = base;
vec->alc = alc - vec->size;