OSDN Git Service

[dsymutil] Force mmap'ing of binaries
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 21 Jun 2018 21:37:53 +0000 (21:37 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 21 Jun 2018 21:37:53 +0000 (21:37 +0000)
commit01b1faf66c252c9cbc9b9f001956672c0f33f681
tree012a5dce3e6504b38e2b66642d75b451144deaa6
parent2c2fae3d83a3f8ec13656086b4727c88d6cc892e
[dsymutil] Force mmap'ing of binaries

After the recent refactoring that introduced parallel handling of
different object, the binary holder became unique per object file. This
defeats its optimization of caching archives, leading to an archive
being opened for every binary it contains. This is obviously unfortunate
and will need to be refactored soon.

Luckily in practice, the impact of this is limited as most files are
mmap'ed instead of memcopy'd. There's a caveat however: when the memory
buffer requires a null terminator and it's a multiple of the page size,
we allocate instead of mmap'ing. If this happens for a static archive,
we end up with N copies of it in memory, where N is the number of
objects in the archive, leading to exuberant memory usage. This provided
a stopgap solution to ensure that all the files it loads are mmap in
memory by removing the requirement for a terminating null byte.

Differential revision: https://reviews.llvm.org/D48397

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335293 91177308-0d34-0410-b5e6-96231b3b80d8
tools/dsymutil/BinaryHolder.cpp